Undoing accidental git stash pop

nren picture nren · Jul 1, 2011 · Viewed 107.6k times · Source

I stashed some local changes before doing a complicated merge, did the merge, then stupidly forgot to commit before running git stash pop. The pop created some problems (bad method calls in a big codebase) that are proving hard to track down. I ran git stash show, so I at least know which files were changed. If nothing else, I guess this is a lesson to commit more.

My question: is it possible to undo the stash pop without also undoing the merge?

Answer

Ben Jackson picture Ben Jackson · Jul 1, 2011

Try using How to recover a dropped stash in Git? to find the stash you popped. I think there are always two commits for a stash, since it preserves the index and the working copy (so often the index commit will be empty). Then git show them to see the diff and use patch -R to unapply them.