我的git存储库有大约2,000个提交.出于教育目的,我一直在玩git rebase -i.
当我键入git rebase -i first-commit(其中first-commit是对repo的初始提交的标记)并且根本不改变任何内容(即pick <hash>保持全部不变)时,git开始重放我的历史记录,但是由于引发冲突而导致数十次提交失败.什么会导致这个?为什么不简单地重播我的整个历史?
我尝试使用开源项目重新创建它,并得到类似的结果,在使用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
Run Code Online (Sandbox Code Playgroud)
似乎冲突发生在接近合并点的地方:
* 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
Run Code Online (Sandbox Code Playgroud)
使用选项-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).
Run Code Online (Sandbox Code Playgroud)
git rebase将改变历史更加线性.由于历史记录中存在合并,因此如果在合并点被展平时存在冲突,则必须解决它们.
| 归档时间: |
|
| 查看次数: |
333 次 |
| 最近记录: |