当我执行git rebase -i HEAD~4
时,会得到如下内容:
pick 7e2dd90 refactor some function
pick dad8a9e fix another bug
pick 4ba8c24 add another feature
pick aca4ba3 do other stuff
pick dd0b3e6 add feature
pick 8dad92f fix bug
pick 8571d0c stuff
pick 25b328c whatever
pick 1803bca demo commit
pick 9723acc hello, world
pick 3ff4212 blahblah
pick c5c3bcf missed a file in merge
当我执行
git log
时,我会得到以下结果:commit c5c3bcf0ac65d1423ddc2785b2f9ac3ecbd930d9
Author: neubert
Date: Sat Mar 28 22:11:08 2015 -0500
missed a file in merge
commit 198bb3c61f62de47706fdfa3171bb79b4a0496a1
Merge: cae37ae bb01002
Author: neubert
Date: Sat Mar 28 21:54:51 2015 -0500
Merge branch 'branchname' into anotherbranch
Conflicts:
path/to/filename.ext
commit bb01002233f1eff5d42b6964e33830633f710ee1
Merge: c8fe3c3 3ff4212
Author: neubert
Date: Sat Mar 28 21:03:17 2015 -0500
Merge remote-tracking branch 'athirdbranchname'
commit 3ff4212b9291f2c863a742f5692ca7312b81decb
Author: neubert
Date: Tue Mar 24 13:40:42 2015 +0800
blahblah
commit 9723acc8853c5fe7ea9bda4a9a711a3e07575c84
Author: neubert
Date: Tue Mar 24 13:38:56 2015 +0800
hello, world
我的问题是:为什么
git rebase
没有显示合并提交?它不支持这种功能吗?我想要将"合并中漏掉的文件"的提交压缩到合并提交中,但如果在rebase中看不到它,我就无法完成这个操作。另外,
git rebase -i HEAD~4
不应该给我四个提交吗,而不是12个吗?
git-rebase
的默认行为。请查看git-rebase
手册页面中的--preserve-merges
标志。至于您的第二个问题,它取决于您提交图的形状;请记住,~
遵循提交的第一个父节点。如果您编辑问题并添加git log --graph --oneline --decorate
的输出,这里的人们将能够更好地解释情况。 - jub0bs