fatal: You have not concluded your merge (MERGE_HEAD exists). means an
earlier merge in this repository stopped on a conflict and was never finished. Git will
not start another merge or pull on top of it. Finish it with git commit, or
throw it away with git merge --abort, then run your command again.
git status tells you which situation you are in. If it says "All conflicts
fixed but you are still merging", one git commit concludes the merge. If you
do not remember starting a merge or do not want its result, abort it and start over.
The error
From git merge:
PS> git merge third
fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you merge.
From git pull, the same state gives a slightly different wording:
PS> git pull . third
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.
Why it happens
When a merge hits a conflict, Git stops halfway and writes .git/MERGE_HEAD
with the id of the commit being merged in. The file stays until the merge is committed or
aborted, because the next commit needs it to record two parents. Many people fix the
conflict markers, run git add, and move on without the final
git commit; the next git pull then finds MERGE_HEAD and stops.
If the conflicts are still unresolved, the message is a different one: in the same test,
before git add, git merge said "Merging is not possible because
you have unmerged files" and git pull said "Pulling is not possible because
you have unmerged files". The MERGE_HEAD message is
specifically the resolved-but-not-committed state:
PS> git status
On branch main
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: price.txt
The fix
Keep the resolution: commit the merge, then repeat the command that failed.
PS> git commit --no-edit
[main 0e4a1dc] Merge branch 'other'
PS> git merge third
Already up to date.
PS> git log --oneline --graph
* 0e4a1dc Merge branch 'other'
|\
| * 60a1408 other price
* | 10759e2 main price
|/
* 8b9139d first
Or drop the half-finished merge and return to where you were before it started:
PS> git merge other
fatal: You have not concluded your merge (MERGE_HEAD exists).
PS> git merge --abort
PS> git status --short
PS> git log --oneline -1
e1e4913 main price
--no-edit keeps Git's default "Merge branch 'other'" message.
git merge --abort, run from the same staged state, put main back
on its commit from before the merge with a clean working folder, so it discards your
conflict resolution too; commit instead if that work is worth keeping.
How it was reproduced
Git for Windows 2.45.2 on Windows 11, Windows PowerShell 5.1, in a throwaway repository.
Branches main and other changed the same line of
price.txt; git merge other conflicted, the file was edited and
staged with git add, and the merge was not committed. A further
git merge exited with 128 and git pull with 128. A commit cleared the
state; in a second repository, brought to the same staged state, git merge
--abort returned main to its previous commit.
Frequently asked
- How do I fix MERGE_HEAD exists in git?
- Run git status. If all conflicts are fixed, run git commit to conclude the merge. If you do not want the merge, run git merge --abort. Then repeat the merge or pull.
- Can I just delete .git/MERGE_HEAD?
- Use git merge --abort or git commit instead. Both were tested and leave the repository in a clean, known state; deleting files inside .git by hand was not.
- Does git merge --abort lose my changes?
- It discards the merge result, including any conflict resolution you made, and puts the branch back on its commit from before the merge. Commit the merge instead if the resolution is worth keeping.
More decoded errors in the Fixes category. For how conflicts arise and how to resolve them, see merge conflicts explained.