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

一笑奈何 提交于 2019-12-08 00:46:57

问题


I have a real bugger of a conflict resolution set, and I figured that I'd just go for it and if I failed, then I should be able to bring back the file into its conflict state. However, I can't seem to find a way to go back. git is still in MERGING state, so how do I backup a single file and reresolve?


回答1:


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.



来源:https://stackoverflow.com/questions/48217712/how-to-move-a-file-back-into-the-conflict-state-after-conflict-resolution

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