我在一个分支上有八个提交,我想通过电子邮件发送给一些还不是git启蒙的人。到目前为止,我所做的每一件事要么给我8个补丁文件,要么开始为分支历史上的每个提交提供补丁文件。我使用了git rebase --交互式的来压缩提交,但是现在我尝试的所有东西都从一开始就给了我无数的补丁。我做错了什么?
git format-patch master HEAD # yields zillions of patches, even though there's
# only one commit since master
发布于 2009-03-05 21:46:59
我建议在一次性分支上这样做,如下所示。如果您的提交是在“newline”分支中,并且您已经切换回了"master“分支,那么这应该可以做到这一点:
[adam@mbp2600 example (master)]$ git checkout -b tmpsquash
Switched to a new branch "tmpsquash"
[adam@mbp2600 example (tmpsquash)]$ git merge --squash newlines
Updating 4d2de39..b6768b2
Fast forward
Squash commit -- not updating HEAD
test.txt | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
[adam@mbp2600 example (tmpsquash)]$ git commit -a -m "My squashed commits"
[tmpsquash]: created 75b0a89: "My squashed commits"
1 files changed, 2 insertions(+), 0 deletions(-)
[adam@mbp2600 example (tmpsquash)]$ git format-patch master
0001-My-squashed-commits.patch
发布于 2009-12-12 16:28:45
只需再添加一个解决方案:如果您使用下面的方法:
git format-patch master --stdout > my_new_patch.diff
那么它仍然是8个补丁...但它们都将位于单个补丁文件中,并将作为一个文件应用:
git am < my_new_patch.diff
发布于 2009-03-05 22:03:21
我总是使用git diff,所以在您的示例中,如下所示
git diff master > patch.txt
https://stackoverflow.com/questions/616556
复制相似问题