Overview
You ran git pull and got:
error: Pulling is not possible because you have unmerged files.
This happens when a previous merge, rebase, or cherry-pick left conflicts unresolved. Git blocks pulling to prevent overwriting unresolved work. The fix is to either resolve the conflicts and complete the operation, or abort it and restore a clean state.
Applies to: Git CLI in DevOps workflows, local development, and CI runners.
Quickstart (TL;DR)
- See what’s wrong:
- git status
- git diff --name-only --diff-filter=U
- If you want to finish the merge:
- Edit conflict markers in files, then git add <files> && git commit
- If you want to abandon the merge:
- For merge: git merge --abort
- For rebase: git rebase --abort
- For cherry-pick: git cherry-pick --abort
- Then pull cleanly (often with rebase):
- git pull --rebase
Minimal Working Example (reproduce and fix)
This demonstrates the error and a safe resolution.
# Setup demo remotes and clones
mkdir -p /tmp/git-unmerged-demo && cd /tmp/git-unmerged-demo
rm -rf remote.git A B
git init --bare remote.git
git clone remote.git A
cd A
printf "v1\n" > app.txt
git add app.txt && git commit -m "init" && git push -u origin main
cd ..
git clone remote.git B
# Conflicting changes in B
cd B
printf "v2-from-B\n" > app.txt
git commit -am "B: change"
git push
cd ..
# Conflicting changes in A
cd A
printf "v2-from-A\n" > app.txt
git commit -am "A: change"
# Pull in A (will cause a merge conflict and leave unmerged files)
set +e
git pull
# Now Git reports conflicts and unmerged paths.
# Resolve by accepting the remote version ("theirs")
# Note: during a pull merge, "theirs" is the remote branch
git checkout --theirs app.txt
git add app.txt
git commit -m "Resolve conflict by taking remote"
git pull --rebase # now clean
Step-by-step resolution
- Identify what’s in progress
- Run git status. It will say one of:
- "You have unmerged paths" and mention "You have not concluded your merge." → merge in progress
- "You are currently rebasing" → rebase in progress
- "You are currently cherry-picking" → cherry-pick in progress
- List unmerged files: git diff --name-only --diff-filter=U
- Option A: Resolve and complete the merge
- For each conflicted file, open it and edit conflict markers (<<<<<<<, =======, >>>>>>>).
- If you want to pick one side entirely:
- Keep local (ours): git checkout --ours -- path/to/file
- Keep remote (theirs): git checkout --theirs -- path/to/file
- Stage and finalize:
- git add path/to/file [repeat for all]
- For merge: git commit (this concludes the merge)
- For rebase: git rebase --continue (repeat until done)
- Pull again if needed (often with rebase): git pull --rebase
- Option B: Abort and try again
- If you want to discard the in-progress operation and return to your last clean commit:
- Merge: git merge --abort
- Rebase: git rebase --abort
- Cherry-pick: git cherry-pick --abort
- After aborting, ensure a clean tree: git status should be clean.
- Then update safely:
- git fetch --all --prune
- git pull --rebase (or explicitly rebase onto the remote branch)
- Option C: Hard reset to the remote (destructive)
- Only if you want to discard local commits and changes:
- git fetch origin
- git reset --hard origin/main
- This obliterates local work; use with caution, typically in CI or ephemeral environments.
Common conflict patterns and quick fixes
- both modified: You must manually reconcile changes or choose a side.
- Keep local for all: git checkout --ours . && git add -A && git commit -m "keep ours"
- Keep remote for all: git checkout --theirs . && git add -A && git commit -m "keep theirs"
- deleted by them/us: One side deleted the file, the other modified it.
- Decide to keep or remove, then run either git add path (to keep) or git rm path (to remove), and commit.
- Binary files: No conflict markers. Choose a side explicitly with --ours/--theirs and commit.
DevOps-focused workflows
- Prefer rebase on pull to maintain a linear history:
- git config --global pull.rebase true
- In CI/CD, avoid pulling into a dirty workspace. Use clean checkouts or hard resets:
- git fetch --all --prune && git reset --hard origin/<branch>
- For long-lived feature branches, pull frequently to reduce conflict size and risk.
- Use pre-merge checks in pipelines (lint/tests) after resolving conflicts before pushing.
Pitfalls to avoid
- Running git pull repeatedly while conflicts exist. Resolve or abort first; otherwise the error persists.
- Using git stash with unmerged files. Stash will refuse unmerged paths; resolve or abort before stashing.
- Accidentally committing conflict markers. Always review with git diff --staged before commit.
- Blind hard resets in developer machines. Ensure you truly want to discard local commits.
- Mixing rebase and merge mid-operation. Finish or abort one operation before starting another.
Performance and workflow notes
- Pull smaller, more often. Smaller diffs mean faster merges and fewer conflicts.
- Favor git pull --rebase to reduce merge commits; less history noise improves blame/log performance.
- Use git status -s and git diff --name-only for quicker overviews on large repos.
- Fetch first on slow networks: git fetch, then review changes before merging or rebasing.
- Large binary files increase conflict cost; track them with Git LFS to reduce repository bloat.
Tiny FAQ
- What causes this error?
- An unfinished merge/rebase/cherry-pick left unmerged files; Git blocks pull until you resolve or abort.
- How do I list unmerged files?
- git diff --name-only --diff-filter=U
- How do I continue after fixing conflicts?
- For merge: git add ... && git commit. For rebase: git rebase --continue.
- Can I force Git to pull anyway?
- No. You must resolve, abort, or reset to get a clean state first.
- Which side is "ours" vs "theirs" during pull?
- "Ours" is your current branch (local HEAD). "Theirs" is the remote branch being merged during pull.