How to fix error: Merging is not possible because you have unmerged files in Git

GitBEGINNERMEDIUMUpdated Dec 6, 2025· 249 views

This error occurs when you attempt to start a new merge while Git is already in a merge state with unresolved conflicts. You must first resolve the existing conflicts from the previous merge, stage the changes, and complete or abort that merge before starting a new one.

Quick fix

Fixes error: Merging is not possible because you have unmerged files

git status
  1. Check the current repository state
  2. View the conflicting changes
  3. Resolve conflicts manually
  4. Use checkout to accept one version entirely
git — error
git status
error: Merging is not possible because you have unmerged files

What this error means

The "error: Merging is not possible because you have unmerged files" message indicates that Git is already in the middle of a merge operation that has encountered conflicts. When you tried to run another merge command, Git refused because the previous merge hasn't been completed. When a merge conflict occurs, Git enters a special "merging" state. In this state, Git has combined as much as it could automatically, but some files contain conflicting changes that require manual resolution. These files are marked as "unmerged" in the working directory. What Git is really telling you: "You are already in a merge state and need to resolve the conflicts there first!" Until you either: 1. Resolve all conflicts and complete the merge with a commit 2. Abort the current merge entirely You cannot start any new merge operations. This is a safety feature to prevent you from getting into an even more confused state.

Typical symptoms

  • Running git merge or git pull fails with 'Merging is not possible because you have unmerged files'
  • git status shows 'You have unmerged paths' and lists files under 'Unmerged paths'
  • Files contain conflict markers (<<<<<<, ======, >>>>>>)
  • Git commands like git checkout fail with 'cannot switch branch' errors
  • CI/CD pipeline fails during merge step with unresolved conflicts
  • git branch shows '(no branch, rebasing)' or similar conflict state

Common causes

  1. A previous merge or pull operation encountered conflicts that weren't resolved
  2. Conflict markers were edited but files weren't staged with git add
  3. The merge was interrupted (terminal closed, process killed) before completion
  4. Attempted to merge while already in a conflicted state from a previous merge
  5. Running git pull which does a merge while having uncommitted changes
  6. Rebase operation left the repository in a conflicted state

How to fix "error: Merging is not possible because you have unmerged files"

1Check the current repository state

First, understand what state your repository is in:

bash
git status

Example output when in merge conflict state:

bash
On branch main
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/app.js
	both modified:   src/config.json

no changes added to commit (use "git add" and/or "git commit -a")

This tells you which files have conflicts that need resolution.

2View the conflicting changes

Use git diff to see what changes are in conflict:

bash
# See all conflicts
git diff

# See conflicts in a specific file
git diff src/app.js

You can also view which files are conflicted:

bash
# List only unmerged files
git diff --name-only --diff-filter=U

This helps you understand what changes need to be reconciled before proceeding.

3Resolve conflicts manually

Open each conflicted file and look for conflict markers:

bash
<<<<<<< HEAD
// Your current branch's version
const port = 3000;
=======
// The incoming branch's version
const port = 8080;
>>>>>>> feature-branch

To resolve:
1. Decide which version to keep (or combine both)
2. Remove all conflict markers (<<<<<<<, =======, >>>>>>>)
3. Save the file

Example resolution (keeping port 8080):

javascript
const port = 8080;

Using VS Code or your editor:
Most modern editors detect conflict markers and provide clickable options:
- "Accept Current Change" (keep HEAD version)
- "Accept Incoming Change" (keep the other branch)
- "Accept Both Changes" (combine both)
- "Compare Changes" (see side-by-side diff)

4Use checkout to accept one version entirely

If you want to accept one side's changes completely:

Accept your current branch's version (discard incoming):

bash
git checkout --ours path/to/file.js

Accept the incoming branch's version (discard yours):

bash
git checkout --theirs path/to/file.js

For all conflicted files:

bash
# Accept all of ours
git checkout --ours .

# Accept all of theirs
git checkout --theirs .

After using checkout, you still need to stage the files with git add.

5Stage the resolved files

After resolving conflicts, mark the files as resolved by staging them:

bash
# Stage a specific resolved file
git add src/app.js

# Stage all resolved files
git add .

Verify all conflicts are resolved:

bash
git status

You should now see:

bash
On branch main
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:
	modified:   src/app.js
	modified:   src/config.json
6Complete the merge with a commit

Once all conflicts are resolved and staged, complete the merge:

bash
git commit

Git will open your default editor with a pre-filled merge commit message:

bash
Merge branch 'feature-branch' into main

# Conflicts:
#	src/app.js
#	src/config.json

Save and close the editor to complete the merge.

Or use a custom message:

bash
git commit -m "Merge feature-branch: resolve config conflicts"

After this, you're out of the merge state and can proceed with new operations.

7Alternatively: abort the merge entirely

If you want to abandon the merge and go back to the state before it started:

bash
git merge --abort

This will:
- Restore your working directory to the state before the merge
- Clear the merge state
- Discard any conflict resolutions you made

Verify the abort worked:

bash
git status

You should see a clean working directory without merge conflicts.

Note: If you have uncommitted changes before the merge, --abort will try to restore them, but this may not always be possible. It's best to commit or stash changes before merging.

8Use a merge tool for complex conflicts

For complex conflicts, use a visual merge tool:

bash
git mergetool

This launches your configured merge tool (vimdiff, meld, kdiff3, VS Code, etc.).

Configure a merge tool:

bash
# Set VS Code as the merge tool
git config --global merge.tool vscode
git config --global mergetool.vscode.cmd 'code --wait $MERGED'

# Set meld as the merge tool
git config --global merge.tool meld

# List available tools
git mergetool --tool-help

After using mergetool:
Git automatically stages resolved files, but creates .orig backup files. Clean them up:

bash
# Remove .orig files
find . -name "*.orig" -delete

# Or configure Git to not create them
git config --global mergetool.keepBackup false
9Reset conflict markers if you need to start over

If you made a mess of resolving conflicts and want to start fresh:

bash
# Re-checkout the file with conflict markers
git checkout --conflict=merge path/to/file.js

This restores the original conflict markers so you can try resolving again.

Or use git restore (Git 2.23+):

bash
# Restore to conflicted state
git restore --conflict=merge path/to/file.js

# Unstage a file without losing changes
git restore --staged path/to/file.js

This is useful when you accidentally removed the wrong code during conflict resolution.

Advanced notes

Prevention: Clean working directory before merging

Always ensure your working directory is clean before starting a merge:

bash
# Check status first
git status

# Stash uncommitted changes if needed
git stash

# Do the merge
git merge feature-branch

# Restore stashed changes
git stash pop

Understanding Merge vs Rebase conflicts

This error can also occur during a rebase operation. The resolution is similar but uses different commands:

bash
# For rebase conflicts
git rebase --abort    # Instead of git merge --abort
git rebase --continue # After resolving, instead of git commit

Rerere: Reuse Recorded Resolution

If you frequently encounter the same conflicts, enable rerere to remember your resolutions:

bash
git config --global rerere.enabled true

Git will record how you resolved conflicts and automatically apply the same resolution next time.

Merge strategies for avoiding conflicts

You can use different merge strategies to handle conflicts:

bash
# Always prefer our changes (use with caution)
git merge -X ours feature-branch

# Always prefer their changes
git merge -X theirs feature-branch

Checking merge base

To understand what's being merged and where conflicts might arise:

bash
# Find the common ancestor
git merge-base main feature-branch

# See what changed on each side since the fork point
git log $(git merge-base main feature-branch)..main
git log $(git merge-base main feature-branch)..feature-branch

Pull vs Fetch + Merge

git pull is actually git fetch + git merge. For more control:

bash
# Fetch changes first (safe, no merge)
git fetch origin

# Review incoming changes
git log HEAD..origin/main

# Then merge when ready
git merge origin/main

This gives you a chance to review changes before potentially creating conflicts.

Frequently asked questions

What does "error: Merging is not possible because you have unmerged files" mean?
The "error: Merging is not possible because you have unmerged files" message indicates that Git is already in the middle of a merge operation that has encountered conflicts. When you tried to run another merge command, Git refused because the previous merge hasn't been completed. When a merge conflict occurs, Git enters a special "merging" state.
How do I fix "error: Merging is not possible because you have unmerged files"?
This error occurs when you attempt to start a new merge while Git is already in a merge state with unresolved conflicts. You must first resolve the existing conflicts from the previous merge, stage the changes, and complete or abort that merge before starting a new one.
What causes "error: Merging is not possible because you have unmerged files"?
A previous merge or pull operation encountered conflicts that weren't resolved Conflict markers were edited but files weren't staged with git add The merge was interrupted (terminal closed, process killed) before completion
Is the "error: Merging is not possible because you have unmerged files" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading