Reputation: 493
During a merge conflict resolution, is there a way to resolve only some conflicts of a file without marking this file as "solved" or checkout the file as conflicted without loosing the hunks already edited?
Currently I'm using vimdiff as mergetool. I have some files that I did a "partial" conflict resolution, but when exit vimdiff with :wqa
the file is automatically marked as "solved".
PS: I know I could use git checkout --conflict=merge myfile.txt
to reset all the conflicts hunks in the file, but I wouldn't keep the conflicts I've already solved as I need to.
Upvotes: 3
Views: 453
Reputation: 60645
Trying it I see the mergetool helper's not set up to handle changing the file and not adding it; if you write changed content but take an error exit from vimdiff (with :cq
) it resets the file.
But nothing's stopping you from doing this yourself. Mergetool's just a convenience wrapper around
vimdiff -c '4winc w' -c 'winc J' `git checkout-index --stage=all myfile.txt`
that does some additional renaming and reordering to make it a little easier to id which is which, cleans up after itself, and either git add
s the result (if you don't :cq
) or git checkout -m
's it if you do. So do that vimdiff yourself and remember b1 b2 b3 is git's stage 1 2 3 content i.e. base ours theirs you can fix up the main file however you want without the helper helpfully git add
ing the result, you'll want to rm .merge_file_*
at some point to clean up the temps.
Or to do this after-the-fact, if you want to keep the partially-merged myfile.txt
that git mergetool
so confidently added as a completed resolution, (edit: it kept bugging me how clunky the way I knew was, sure enough there's been a direct way to do it since oh, Git v1.4 or so)
git update-index --unresolve myfile.txt
Upvotes: 3