Skip to content

git stash pop conflict

Quick summary

You ran git stash pop but the stashed changes conflict with changes you made since stashing — git stops and leaves conflicts in your working tree.

Why this happens

  • You edited the same lines after stashing that the stash itself modifies, creating an unavoidable overlap

  • The stash was created on a different branch and the surrounding context has since changed significantly

  • You popped a stash that was created from uncommitted merge conflict resolutions that no longer apply

Minimal example

✗ Broken code
git stash
echo 'new line' >> file.txt
git stash pop  # CONFLICT!
✓ Fixed code
git stash
echo 'new line' >> file.txt
git commit -am 'wip'
git stash pop  # clean pop, no conflict

Committing current changes before popping the stash gives git a clean base to apply the stash onto, avoiding the conflict.

How to diagnose

  • Run git status to see which files have conflict markers (<<<<<<<) from the failed stash pop

  • Use git stash list to confirm which stash entry you attempted to pop and its original branch

  • Check git diff to inspect the conflicting hunks and decide which version to keep

How to fix

  • Resolve each conflicted file manually by removing conflict markers and keeping the correct lines, then git add and git stash drop

  • Pop the stash into a separate branch with git stash branch new-branch to avoid conflicts in the current tree

  • If the stash is no longer needed, run git stash drop to discard it after confirming the conflicts are unwanted

How to prevent

  • Always commit or stash current changes before popping an older stash to keep the working tree clean

  • Use git stash pop immediately after stashing to minimize divergence between the stash and working tree

Related Resources

Related Glossary

Related Lessons

  • git stash

    Learn how to stash and restore changes.

← Back to language