bob.sacamento bob.sacamento - 22 days ago 6
Git Question

git -- how to recover from unfinished merge

I started the mergetool ...

> git mergetool


And it said something like ...

merge tool candidates: blah blah blah
Merging:
file1.c


And then I thought, "You know, I'm not ready for this." Not knowing any clean way to shut it down, I hit ctrl-C. Now I want to check out another branch, but I can't ...

> git checkout other_branch
error: path 'file1.c' is unmerged


Is there some way to recover from this? I emphasize that I made no actual changes when mergetool was running.

Answer

You're looking for the --abort option which exists in most git commands:

git merge --abort

Manual entry:

Abort the current conflict resolution process, and try to reconstruct the pre-merge state.