The answer here很好地解释了如何在推送后压缩最后几次提交,但是例如呢?最后12人分成三组,每组四人?也就是说,我已经推送了 1-12 次提交,现在想将它们压缩为 3 次提交。这三个压缩的提交将分别包含原始提交 1-6、7-8 和 9-12。我怎样才能做到这一点?
奖励点:如何为三个压缩的提交中的每一个指定新的提交消息?
最佳答案
您可以一次压缩多组提交:
git rebase -i HEAD~15
pick 3f3416d T11 - some issue
pick 23031eb T12 - fix
pick 8239b70 T13 - improvements
squash e1e23fd T13 - one more fix
squash 200c8c6 T13 - last fix
pick e5b0286 T14 - great feature
pick d18bf1b T15 - removing unused files
pick a1b1821 T16 - refactor part 1.
squash dd090dc T16 - refactor part 2.
squash d87db6b T16 - refactor part 3.
pick da1dd09 T17 - new model of database
pick 39b4ace T18 - restfull api
pick 65521eb T19 - registration form
squash 8924091 T19 - login form
pick b44a25c T20 - new super feature
在 rebase 期间,您将被询问每个组的新提交消息:
1组
# This is a combination of 3 commits.
# The first commit's message is:
T13 - improvements
# This is the 2nd commit message:
T13 - one more fix
# This is the 3rd commit message:
T13 - last fix
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author: Your Name <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1a63756f68347f777b73765a7e75777b737434797577" rel="noreferrer noopener nofollow">[email protected]</a>>
# ...
2组
# This is a combination of 3 commits.
# The first commit's message is:
T16 - refactor part 1.
# This is the 2nd commit message:
T16 - refactor part 2.
# This is the 3rd commit message:
T16 - refactor part 3.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author: Your Name <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e67716b6c307b737f77725e7a71737f7770307d7173" rel="noreferrer noopener nofollow">[email protected]</a>>
# ...
3组
# This is a combination of 2 commits.
# The first commit's message is:
T19 - registration form
# This is the 2nd commit message:
T19 - login form
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author: Your Name <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="80f9eff5f2aee5ede1e9ecc0e4efede1e9eeaee3efed" rel="noreferrer noopener nofollow">[email protected]</a>>
# ...
关于git - 压缩推送的提交组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31688620/