KhueApps
Home/DevOps/How to fix 'You have not concluded your merge' (MERGE_HEAD present)

How to fix 'You have not concluded your merge' (MERGE_HEAD present)

Last updated: October 07, 2025

What this error means

Git created a merge commit but stopped because there are conflicts or the merge was left incomplete. The presence of .git/MERGE_HEAD tells Git a merge is in progress. Until you resolve or abort it, commands like checkout or pull may fail with a message similar to: you have not concluded your merge.

Common triggers:

  • git merge <branch>
  • git pull (when it performs a merge)
  • Interrupted conflict resolution, editor closed early, or pending conflicted files

Quickstart

  • To finish the merge after resolving conflicts:
    • git add <files>
    • git merge --continue (or: git commit)
  • To cancel the merge and go back:
    • git merge --abort (fallback: git reset --merge)
  • To check what remains:
    • git status --porcelain=v1 -u

Minimal working example (reproduce and fix)

# Create two branches with a conflicting change
mkdir demo-merge && cd demo-merge
git init
printf 'line1\n' > file.txt
git add file.txt && git commit -m 'init'

git checkout -b feature
printf 'feature change\n' > file.txt
git commit -am 'feature edit'

git checkout -b main origin 2>/dev/null || git checkout -B main
printf 'main change\n' > file.txt
git commit -am 'main edit'

# Start merge (will conflict)
git merge feature || true

# You are now in a merge state (MERGE_HEAD exists)
git status

# Resolve: pick main version, for example
echo 'main change' > file.txt

git add file.txt
# Conclude the merge
git merge --continue  # or: git commit --no-edit

git log --oneline --graph --decorate -n 3

Step-by-step resolution

  1. Confirm merge-in-progress
  • git status
  • Optional: test -f .git/MERGE_HEAD && echo 'merge in progress'
  1. Decide: finish or abort
  • Finish if you want to integrate the other branch.
  • Abort if the merge was accidental or must be redone.
  1. If finishing the merge
  • List conflicts:
    • git status --porcelain=v1 -u | grep '^UU' || true
  • For each conflicted file:
    • Open and resolve conflict markers (<<<<<<<, =======, >>>>>>>)
    • Run git add <file>
  • When all conflicts are staged:
    • git merge --continue (or git commit to complete the merge)
  1. If aborting the merge
  • Preferred:
    • git merge --abort
  • If that fails (older Git or unusual state):
    • git reset --merge
  • If you need to return exactly to pre-merge state:
    • git reset --hard ORIG_HEAD
  1. Protect uncommitted work (optional)
  • If you have unrelated edits you do not want to lose:
    • git stash push -u -m 'pre-merge-safety'
    • After fixing/aborting, restore with: git stash pop

Common scenarios and commands

GoalCommand(s)
Continue merge after resolving conflictsgit add <files>; git merge --continue
Commit without editing the messagegit commit --no-edit
Abort merge safelygit merge --abort
Abort merge (fallback)git reset --merge
Fully revert to pre-mergegit reset --hard ORIG_HEAD
See remaining conflictsgit status --porcelain=v1 -u

Notes:

  • git merge --continue is available on modern Git; git commit works on all versions to conclude a merge once everything is staged.
  • When merge was started by git pull, the same commands apply.

Troubleshooting

  • merge --continue complains about unresolved paths
    • Run git status to see files with UU status; fix them and git add each file.
  • No conflicts shown, but Git still says merge in progress
    • Try git commit or git merge --continue to finalize.
    • Ensure there is no pre-commit hook failing the commit.
  • merge --abort fails
    • Use git reset --merge; if needed, git reset --hard ORIG_HEAD (be aware this discards uncommitted changes).
  • Nested operations
    • If you were rebasing or cherry-picking, use the corresponding command (git rebase --continue or git cherry-pick --continue). The error here specifically indicates a merge, so complete or abort the merge first.

Pitfalls

  • Using git reset --hard blindly
    • This discards local changes. Stash first if you care about them.
  • Adding everything with git add -A during a merge
    • May stage unintended files. Prefer adding only resolved paths.
  • Manually deleting .git/MERGE_HEAD
    • Avoid unless you fully understand the state; use merge --abort or reset methods.
  • Confusing merge with rebase
    • The fix differs: for rebase use git rebase --continue or git rebase --abort. For merges use merge commands.

Performance notes

  • Speed up status scans on large repos
    • Use git status --porcelain=v1 -u for faster machine-friendly output.
  • Resolve only touched files
    • Limiting git add to specific conflicted paths avoids unnecessary index work.
  • Reuse conflict resolutions
    • Enable rerere to auto-apply known resolutions across repeated merges: git config --global rerere.enabled true
  • Avoid repeated large merges
    • Consider merging more frequently or rebasing regularly to reduce conflict sets and re-merge cost.

Preventing future occurrences

  • Prefer linear history if suitable: use rebase (git pull --rebase) to reduce merge commits. Ensure your workflow and policy allow this.
  • Merge often from main into long-lived branches to minimize drift and conflicts.
  • Keep pre-commit and merge hooks deterministic; failing hooks can block the concluding commit.

FAQ

  • What is MERGE_HEAD?
    • A file in .git recording the commit being merged; its presence means a merge is in progress.
  • What is ORIG_HEAD?
    • The previous HEAD before a risky operation (like merge). Useful for resets.
  • Can I conclude a merge with commit instead of merge --continue?
    • Yes. Once all conflicts are staged, git commit finalizes the merge.
  • Does git pull cause this?
    • Yes, when pull performs a merge and conflicts arise.
  • How do I list only conflicted files?
    • git status --porcelain=v1 -u | awk '/^UU/ {print $2}'
  • Is merge --abort safe?
    • Yes; it attempts to restore the pre-merge state without discarding unrelated uncommitted work.

Series: Git

DevOps