幂等git rebase因虚假冲突而失败?

时间:2012-03-27 23:42:41

标签: git git-rebase

我的git存储库有大约2,000次提交。出于教育目的,我一直在玩git rebase -i

当我键入git rebase -i first-commit(其中first-commit是对repo的初始提交的标记)并且根本不更改任何内容(即保持所有pick <hash>不变)时,git开始重播我的历史,但几十个提交引用冲突失败。什么会导致这个?为什么不简单地重播我的整个历史?

1 个答案:

答案 0 :(得分:6)

我尝试使用开源项目重新创建它,并获得了类似的结果,在使用rebase交互式首次提交时进行重新定位时报告了冲突。

我第二次跑了,发现它发生在同一次提交中。

git clone git://git.lttng.org/lttng-tools.git
git tag first-commit fac6795
git rebase -i first-commit

Could not apply e4baff1... listing and activation of loglevel by number
git rebase --abort

似乎冲突恰好发生在合并点附近:

* 843f5df (HEAD, tag: new-tag) API change for lttng_destroy_session prototype
*   90192ee Merge branch 'master'
|\  
| * 4dbd54a update loglevel printout
| * e4baff1 listing and activation of loglevel by number
* | 76d45b4 Add support for UST enable all tracepoints
* | 6181537 Cleanup lttng enable event command
|/  
* 13dce3b loglevels: allow enable/disable
* 81afa34 Add loglevel to event list
* 57ab763 ABIs now support 256 char event names

使用选项-p再次运行rebase但是成功了:

-p, --preserve-merges
           Instead of ignoring merges, try to recreate them.

           This uses the --interactive machinery internally, but combining it with the --interactive option explicitly is generally not a
           good idea unless you know what you are doing (see BUGS below).

git rebase会将历史记录更改为线性。由于历史记录中存在合并,因此如果合并点被展平,则必须解决这些问题。