🔀 Git: Fix a Stash Pop Conflicting With Unrelated Untracked Files
A stash created with –include-untracked bundles untracked files into the stash alongside tracked changes, which is exactly what you want right up until a new, unrelated untracked file with the same path gets created in the working directory before you pop. Git refuses to overwrite that file to restore the stashed one, and the error reads like a generic conflict rather than the specific, easy-to-understand path collision it actually is.
🔎 The Problem
$ git stash push -u -m "wip: exporter" # later, a different unrelated process creates: $ touch build/output.tmp $ git stash pop error: Untracked working tree file 'build/output.tmp' would be overwritten by merge. # The NEW output.tmp has nothing to do with the stashed one - # they just happen to share a path.
✅ Fix: Resolve the Path Collision Before You Pop
- Run
git statusandgit stash show -u stash@{0}before popping to compare what’s currently untracked against what the stash expects to restore, catching path collisions before Git does. - Move or rename the conflicting untracked file out of the way temporarily, pop the stash normally, then decide whether the moved file still needs to come back or was disposable all along.
- If the colliding file genuinely doesn’t matter, delete it and pop again — but confirm that deliberately, since
git stash pophas no force flag that overwrites untracked files for you automatically.
🚨 Why This Is Dangerous
- Deleting the wrong file to clear a pop conflict, without first checking what it actually is, can throw away in-progress work from a completely unrelated task that just happened to write to the same path.
A stash remembers a path, not a promise that nothing else will ever use it in the meantime — check what’s actually sitting there before asking Git to put something else back.

