Git "You have not concluded your merge" and nothing to commit?

Git

Git Problem Overview


Whenever I try to push in Git I get this:

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

Running git status I get:

# On branch master
nothing to commit (working directory clean)

Or running git ls-files -u I get nothing.

Running git add .and trying again makes no difference.

What's up?

Git Solutions


Solution 1 - Git

Okay I finally found answer: git commit -m "Test" apparently fixed this. The result was an empty commit with no changes whatsoever. Even Github shows an empty commit, but it works.

Solution 2 - Git

Did you end up with an empty merge commit (two parents) or just an empty commit? In the latter case, you could have deleted .git/MERGE_HEAD.

Update: Rather than delete MERGE_HEAD by hand, you could also use git merge --abort (as of git 1.7.4) or git reset --merge (as of git 1.6.2).

It's also worth mentioning that at least as of git 1.8.3 (maybe earlier?) you should see a status message like this if an actual merge is in progress and needs to be committed (if you specified --no-commit, for example):

# On branch master
# All conflicts fixed but you are still merging.
#   (use "git commit" to conclude merge)
#
nothing to commit, working directory clean

If you don't see this and still get the MERGE_HEAD warning, something is messed up and you should probably just --abort to get back to a clean state.

Additional Detail from Comments

During a merge, git creates a MERGE_HEAD file in the root of the .git folder (next to HEAD, ORIG_HEAD, probably FETCH_HEAD, etc) to track information about the merge in progress (specifically, the SHA(s) of the commit(s) being merged into the current HEAD). If you delete that, Git will no longer think a merge is in progress. Obviously, if a merge really is in progress then you wouldn't want to delete this file.

Solution 3 - Git

Use git reset command, without parameters. Docs

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTowerView Question on Stackoverflow
Solution 1 - GitTowerView Answer on Stackoverflow
Solution 2 - GitdahlbykView Answer on Stackoverflow
Solution 3 - GitAndrei KonstantinovView Answer on Stackoverflow