Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

Git refuses to pull or merge because an earlier merge is still open

Your error

error: You have not concluded your merge (MERGE_HEAD exists).3 more lines it can show

Fix it fast

Most common cause, 1 of 3

Conflicted 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.

Fix
git mergetool            # optional, opens your configured merge tool
git add path/to/resolved-file
git merge --continue
Did this fix it?
Full steps for this cause: check, fix, verify

Short 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.

  • Applies to Git 2.56.1, Git 2.x on Linux, macOS and Windows
  • Updated
  • By Maaz Zindani, Senior Software Engineer

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).

Run this first
git status

Then find the line you see in this list and open its fix:

  1. 1Conflicted files have not been resolved and stagedgit status prints You have unmerged paths and lists files as both modified
  2. 2Every conflict is staged, but the merge commit was never madegit status prints All conflicts fixed but you are still merging
  3. 3The merge was a mistake and should be thrown awayThe 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.

Check
git diff --name-only --diff-filter=U

Fix

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.

Fix
git mergetool            # optional, opens your configured merge tool
git add path/to/resolved-file
git merge --continue

Verify

git status reports a clean tree on your branch, and git log shows the new merge commit at the top.

Verify
git log --oneline --graph -5

Confirmed by git-scm.com

Did this fix it?

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.

Check
git rev-parse -q --verify MERGE_HEAD

Fix

Create the merge commit. git merge --continue first checks that a merge really is in progress and then runs git commit for you.

Fix
git merge --continue

Verify

git rev-parse prints nothing for MERGE_HEAD, and the pull that failed now runs.

Verify
git rev-parse -q --verify MERGE_HEAD || git pull

Confirmed by git-scm.com

Did this fix it?

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.

Check
git log --oneline -1 MERGE_HEAD

Fix

Abort the merge, then start again later from a clean working tree.

Fix
git merge --abort
git status

Verify

git status shows your branch with no merge in progress, and the conflict markers are gone from the files.

Verify
git status --short

Confirmed by git-scm.com

Did this fix it?

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.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.