Git: How do I re-resolve a merge conflict (before the merge)?

I did

git merge FETCH_HEAD

and after git told me that there is a conflict in one file, I did

git mergetool

which in my case runs SourceGear DiffMerge as a mergetool GUI. Immediately after saving the merged file, I realized that I had made a bad mistake. I just want to forget about the merger and do it all.

Since I haven't done git add yet, but not to mention that I did something, I thought I could erase my mistake and repeat the merge easily as follows:

git reset FILENAME
git merge FETCH_HEAD
git mergetool

This does not work. "git merge" by this time tells me

fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you can merge.

But, of course, I do not want to make a convoluted merger. "git mergetool" complains

No files need merging

I assume I made a mistake in the git reset command. What is the right way to do this?

ADD:

I did

git merge --abort

then again:

git merge FETCH_HEAD

error: Your local changes to the following files would be overwritten by merge: ...

git status

:

On branch ....
Your branch is up-to-date with ......
Changes not staged for commit:
    modified:   nVP.ini
Untracked files:
    nVP.ini.orig
no changes added to commit (use "git add" and/or "git commit -a")

: git checkout nVP.ini ?

+4
1

, git checkout -m -- $thefile.

$ git merge 3fac3
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
Automatic merge failed; fix conflicts and then commit the result.
$ vi file.txt         # fix all the conflicts. do it wrong.
$ git add file.txt    # <--- ooops
$ git checkout -m -- file.txt    # <--- the correct un-oops-ifier here

file.txt .

, , , , , git checkout -m --conflict diff3 -- file.txt.

+9

All Articles