Git "error: path is unmerged" and "You need to resolve your current index first": How to Fix Them
Git error path is unmerged means a merge, rebase or stash pop left a conflict. Learn how to finish it with git add, redo or pick one side, or back out safely.
Git's "error: path '...' is unmerged" means a merge, rebase, cherry-pick or git stash pop stopped on a conflict in that file, and the conflict hasn't been marked as resolved yet. Until it is, Git refuses commands that need a clean index, such as switching branches, stashing or committing. Fix it by editing the file and running git add on it, or back out of the operation with git merge --abort (or git reset --merge after a stash pop).
Checked against the Git manuals for git merge, git restore and git stash, Git's source code, and by reproducing each message with Git 2.43 in November 2026.
The messages you might see
The wording depends on which command you ran while the conflict was open. If you tried to undo a file with git checkout -- file or git restore file:
error: path 'src/app.js' is unmerged
If you tried to switch branches with git checkout:
src/app.js: needs merge
error: you need to resolve your current index first
If you tried git stash, Git prints the needs merge line and saves nothing. And if you tried to commit, pull or merge again:
error: Committing is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
They all mean one or more files are still conflicted.
What "unmerged" means
The index (also called the staging area) is the list of what goes into your next commit. Normally each file has one entry there. During a conflict, Git stores up to three versions of the conflicted file instead: the common ancestor, your side ("ours") and the incoming side ("theirs"). A file in that state is "unmerged".
It stays unmerged until you tell Git which content to keep, which you do with git add (or git rm if the answer is to delete it). Editing the file and removing the <<<<<<< markers isn't enough on its own; Git only checks the index.
Step 1: see what you're in the middle of
git status
The top of the output tells you which operation is paused:
git status says |
You're in the middle of | Finish with | Back out with |
|---|---|---|---|
You have unmerged paths. and use "git merge --abort" |
A merge (or git pull that merged) |
git commit or git merge --continue |
git merge --abort |
You are currently rebasing |
A rebase (or git pull --rebase) |
git rebase --continue |
git rebase --abort |
You are currently cherry-picking |
A cherry-pick | git cherry-pick --continue |
git cherry-pick --abort |
Only Unmerged paths:, no operation named |
Usually a conflicted git stash pop or git stash apply |
git add, then git stash drop |
git reset --merge |
Below that, Unmerged paths: lists the files, usually marked both modified:. git status --short shows them with UU.
Fix 1: resolve the conflict and mark it (the normal path)
This is what Git expects you to do. For each unmerged file:
Open it and find the conflict markers:
<<<<<<< HEAD your version ======= their version >>>>>>> featureEdit it into the version you want and delete all three marker lines.
Mark it resolved:
git add src/app.js
When git status no longer lists unmerged paths, finish the operation with the command from the table: git commit (or git merge --continue) for a merge, git rebase --continue for a rebase. If reading conflict markers is new to you, Merge Conflicts Explained walks through it with examples.
After a conflicted stash pop
git stash pop that hits a conflict behaves differently from a merge. The Git manual says the stash entry "is not removed from the stash list"; Git even prints The stash entry is kept in case you need it again. There's no merge to commit, either. Your changes were meant to stay uncommitted.
So after resolving the file:
git add src/app.js # marks the conflict resolved
git restore --staged src/app.js # optional: unstage it again, keeping your edits
git stash drop # remove the stash entry now that it's applied
Only run git stash drop once you're happy with the result, because that is the step that deletes the saved copy. (Git Stash Explained covers stash in more depth.)
Fix 2: take one side for a whole file
If you know one version is simply right (a lock file, a generated file, or a file you didn't mean to touch), you don't have to edit markers:
git checkout --theirs -- package-lock.json # take the incoming version
# or
git checkout --ours -- package-lock.json # keep your version
git add package-lock.json
git restore --ours and git restore --theirs do the same thing. Two cautions:
- The file stays unmerged until the
git add. Checking out one side only changes the working copy. - During a rebase, "ours" and "theirs" appear swapped, because Git is replaying your commits on top of the other branch. The
git restoremanual warns about exactly this. Look at the file afterwards to be sure you got the side you meant.
Fix 3: you messed up a resolution and want the conflict back
This is where "path is unmerged" often comes from: you edited a conflicted file, didn't like the result, ran git checkout -- file to undo it, and Git refused. Plain checkout -- and restore don't know which of the three versions you want.
To put the conflict markers back and start that file over:
git restore --merge src/app.js
# older equivalent:
git checkout -m -- src/app.js
The git restore manual describes --merge as "recreate the conflicted merge in the unmerged paths." In our test it also restored the conflict for a file already resolved with git add, while the merge was still open.
Fix 4: back out of the whole operation
To return to where you were before the merge, rebase or cherry-pick started:
git merge --abort # or: git rebase --abort, git cherry-pick --abort
The git merge manual has a warning worth knowing: if you had uncommitted changes when the merge started, git merge --abort "will in some cases be unable to reconstruct" them. That's why it recommends committing or stashing before you merge.
After a conflicted git stash pop, there is no merge to abort. git merge --abort fails with fatal: There is no merge to abort (MERGE_HEAD missing). Use this instead:
git reset --merge
That clears the conflict and puts the conflicted files back to your last commit. Because the stash entry was kept, nothing from the stash is lost; check with git stash list. Any other uncommitted edits you made to those same files would be gone, so look at git status first.
Last resort
git reset --hard HEAD also clears an unmerged index, but it throws away every uncommitted change in the repository, not just the conflict. Use it only when you're sure there's nothing in your working tree you want to keep. If you need a refresher on which reset does what, see git reset vs git revert.
A trap: switching branches halfway through a merge
git switch refuses to change branches while a merge is in progress (fatal: cannot switch branch while merging). The older git checkout <branch> is less careful. Once you've git add-ed the conflicted files, it may switch branches without complaint and quietly drop the "merge in progress" state, carrying your half-merged changes along as ordinary edits. When we tried this, git merge --abort afterwards reported there was no merge to abort.
The safe habit: finish the merge with a commit, or abort it, before you switch branches. Using git switch instead of git checkout for branches gives you that check for free.
Quick reference
git statusto see which operation is paused and which files are unmerged.- To finish: edit the files,
git addeach one, then commit or--continue. - To take one side:
git checkout --ours/--theirs -- file, thengit add. - To redo a file's conflict:
git restore --merge file. - To give up:
git merge --abort(orrebase/cherry-pick --abort); after a stash pop,git reset --merge.
If an AI agent such as Claude Code is doing your merges, the same rules apply, and asking it to run git status first saves a lot of guessing. On EasySpawn the agent works in a persistent server's real Git repository, and the terminal shows each command it runs, so you can see exactly where a merge stopped. See how it works.
Related: Merge Conflicts Explained: What They Are and How to Fix Them · Git Stash Explained: Save Unfinished Work Without Committing · git reset vs git revert: Which One Should You Use to Undo? · Git Rebase vs Merge: What's the Difference and When to Use Each
Keep reading
SSH "Exit Status 255": What It Means and How to Find the Real Error
SSH error 255 means ssh itself failed to connect, verify the host or log in. Find the real cause with ssh -v and fix it, including in CI and VS Code.
npm "Missing script: dev" (or "start"): What It Means and How to Fix It
npm error Missing script dev means the package.json npm found has no dev script. Check the folder, list scripts with npm run, and use the right name.