Git revert causes merge conflict

自闭症网瘾萝莉.ら 提交于 2020-12-05 11:40:14

问题


I created a dummy txt file and entered a new line in every commit such as:

//dummy.txt
first commit
second commit
third commit

now I want to get rid of the second line by reverting the second commit. However I receive merge conflicts in this simple experiment. Could somebody explain why?


回答1:


Your example is actually not as trivial as you may think, because your changes are all on consecutive lines. The main problem is that the diff introduced by third commit actually depends on changes done in second commit. Git stores the full tree of each commit, but still needs to be able to express a commit as a diff in terms of the previous commit (don't know if that makes sense to you).

If you try the same operations but by doing 3 commits modifying different parts of the same file, the revert of the second commit will not fail. Since the default context diff is 3, it should not fail if your edits are further than 3 lines apart from each other.



来源:https://stackoverflow.com/questions/30713730/git-revert-causes-merge-conflict

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