Is merge without conflicts equivalent to rebase without conflicts?

送分小仙女□ 提交于 2019-12-12 11:23:54

问题


Is it correct that a git merge will succeed with no conflicts if and only if the corresponding git rebase will succeed with no conflicts?


回答1:


No, and in fact there's a trivial case where merge works fine but rebase doesn't:

...--o--A   <-- mainline
      \
       B--C--!C   <-- branch

where C is a commit that conflicts with A, and !C is its reversion. Merging branch back into mainline is equivalent in source-tree effect to merging commit B back into mainline, while rebasing copies both C (which conflicts with A) and then !C (which when being resolved, also conflicts with A).

Of course, you can rebase interactively and simply drop both C and !C in this case, but in more complex chains, you can see how a commit might conflict with A but a subsequent commit might effectively resolve that conflict "in advance", so that merging the tip of the branch back into the mainline has no conflicts.



来源:https://stackoverflow.com/questions/44530822/is-merge-without-conflicts-equivalent-to-rebase-without-conflicts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!