Git refuses to pull or merge because an earlier merge is still open
Fix it fast
Most common cause, 1 of 3Conflicted files have not been resolved and staged
Open each listed file, keep the right lines, delete the markers, and stage it. git mergetool can walk you through the files one by one.
git mergetool # optional, opens your configured merge tool
git add path/to/resolved-file
git merge --continueShort answer
Git prints You have not concluded your merge (MERGE_HEAD exists) when an earlier merge or pull stopped unfinished, so .git/MERGE_HEAD remains and Git refuses to start another. Run git status, then resolve and git add any unmerged paths and finish with git merge --continue, or cancel everything with git merge --abort. Applies to Git 2.x, including 2.56.
Which cause do you have?
Ask Git what state the merge is in. You have unmerged paths means conflicts are still open (cause 1). All conflicts fixed but you are still merging means only the commit is missing (cause 2).
git statusThen find the line you see in this list and open its fix:
- 1Conflicted files have not been resolved and staged
git status prints You have unmerged paths and lists files as both modified - 2Every conflict is staged, but the merge commit was never made
git status prints All conflicts fixed but you are still merging - 3The merge was a mistake and should be thrown away
The pull or merge targeted the wrong branch, or the conflicts are not worth resolving now
What does the error look like?
error: You have not concluded your merge (MERGE_HEAD exists).hint: Please, commit your changes before merging.fatal: Exiting because of unfinished merge.error: Pulling is not possible because you have unmerged files.
Cause 1 of 3
Conflicted files have not been resolved and staged
You seegit status prints You have unmerged paths and lists files as both modified
Check
While conflicts remain, the index holds several versions of each conflicted path and the files contain <<< === >>> markers. Git will not begin a new merge or pull on top of that, so a fresh pull stops with Pulling is not possible because you have unmerged files.
git diff --name-only --diff-filter=UFix
Open each listed file, keep the right lines, delete the markers, and stage it. git mergetool can walk you through the files one by one.
git mergetool # optional, opens your configured merge tool
git add path/to/resolved-file
git merge --continueVerify
git status reports a clean tree on your branch, and git log shows the new merge commit at the top.
git log --oneline --graph -5Confirmed by git-scm.com
Cause 2 of 3
Every conflict is staged, but the merge commit was never made
You seegit status prints All conflicts fixed but you are still merging
Check
Staging the resolved files is not the end of a merge. The MERGE_HEAD ref keeps pointing at the other branch until a commit records both parents, and until then pull, merge and similar commands stop with the MERGE_HEAD message.
git rev-parse -q --verify MERGE_HEADFix
Create the merge commit. git merge --continue first checks that a merge really is in progress and then runs git commit for you.
git merge --continueVerify
git rev-parse prints nothing for MERGE_HEAD, and the pull that failed now runs.
git rev-parse -q --verify MERGE_HEAD || git pullConfirmed by git-scm.com
Cause 3 of 3
The merge was a mistake and should be thrown away
You seeThe pull or merge targeted the wrong branch, or the conflicts are not worth resolving now
Check
A stopped merge can also be cancelled. git merge --abort rebuilds the state from before the merge, and while MERGE_HEAD is present it does the same as git reset --merge. Edits that were uncommitted when the merge began may not survive, so stash or commit them first next time.
git log --oneline -1 MERGE_HEADFix
Abort the merge, then start again later from a clean working tree.
git merge --abort
git statusVerify
git status shows your branch with no merge in progress, and the conflict markers are gone from the files.
git status --shortConfirmed by git-scm.com
How do I stop it coming back?
- Commit or stash local edits before git pull or git merge, so an abort can always restore the previous state.
- Run git config pull.ff only in a repository where pulls should never create merges; Git then refuses any pull that is not a fast-forward instead of starting a merge.
- Run git status after every pull in scripts and stop the job when it reports unmerged paths.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.