[英]Squash commits with commits from merged branch in between
在分支BRANCH_SOMETHING上有這樣的情況:
FFF - 6th commit
EEE - 5th commit
DDD - 4th commit
Y commit from master
X commit from master
CCC - 3rd commit
BBB - 2nd commit
AAA - 1st commit
如何僅壓縮我的提交?
您必須運行的命令是git rebase -i AAA~
(注意~
),它將使用以下rebase程序打開您的默認文本編輯器:
pick AAA 1st commit
pick BBB 2nd commit
pick CCC 3rd commit
pick X commit from master
pick Y commit from master
pick DDD 4th commit
pick EEE 5th commit
pick FFF 6th commit
您必須將文本編輯為如下所示:
pick X commit from master
pick Y commit from master
pick AAA 1st commit
squash BBB 2nd commit
squash CCC 3rd commit
squash DDD 4th commit
squash EEE 5th commit
squash FFF 6th commit
保存並退出文本編輯器。
Git將運行,然后再次打開文本編輯器,使您有機會編輯提交消息:
# This is a combination of 6 commits.
# This is the 1st commit message:
1st commit
# This is the commit message #2:
2nd commit
...
編輯提交消息,保存並退出。
最終,歷史將如下所示:
GGG squashed commit
Y commit from master
X commit from master
請注意,您還可以將提交X和Y放置在被壓縮的提交之后,相應地突出顯示重新設置程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.