ChatGPT解决这个技术问题 Extra ChatGPT

Restart/undo conflict resolution in a single file

In a larger git merge with several conflicting files, I incorrectly marked a file as resolved (using git add FILE after some editing)

Now I'd like to undo my conflict resolution attempt and start over resolving that file.

How can I do that?


A
Alex Krauss

Found the solution here: http://gitster.livejournal.com/43665.html

git checkout -m FILE

This restores the unresolved state, including all information about parent and merge base, which allows restarting the resolution.


+1; this is the actual solution :) git reset won’t touch the file.
Didn't work for me, file is still marked with both modified (in conflict state)
This really helped me out since it put the file back into it's pre-conflict resolution state. What's interesting is that instead of the two merge points being named "head" and {REVISION}, they're now called "ours" and "theirs".
"file is still marked with both modified". That's exactly the intended result of the question.
-m as in --merge