How to move a file back into the conflict state after conflict resolution?

匆匆过客 提交于 2019-12-06 10:41:34

First, if you think you might have a decent resolution (or part of it), copy the file somewhere else. :-) Then just run:

git checkout -m -- path

(the -- part is needed only if the file's path resembles a valid git checkout option, e.g., if the file you want to put back in conflicted state is named --theirs or -f or some such). This will re-create the conflict-marker variant of the file from the three inputs (merge base and both branch heads), and write that file to the work-tree.

Note that you can specify the --conflict=merge (default) style, or the --conflict=diff3 style. This is the same as setting merge.conflictStyle in .gitconfig, but just for that one file and this one checkout.

If you (or git mergetool) used a merge tool that already ran git add on the resolved variant, note that this puts the file back into conflicted state, i.e., it restores the three higher stage entries into the index. You can now run git mergetool again, or—my personal preference—just manually edit the conflicted file and git add the resulting work-tree copy once you are satisfied that it is correct.

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