Search code examples
gitgit-stash

Undo git stash pop on dirty working tree


This seems very foolish mistake, I just did a git stash pop on a dirty working tree. I do not know any way of keeping the desired changes and undoing the stash pop. Does one exist? Or such a mistake is unforgivable?


Solution

  • If you still have that stash's SHA1, you can generate a patch from it (git format-patch SHA1) and apply the patch in reverse (git apply -R filename.patch).

    If you lost the SHA1, see How to recover a dropped stash in Git?