0xc0de
0xc0de

Reputation: 8287

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?

Upvotes: 16

Views: 4494

Answers (2)

adl
adl

Reputation: 16044

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?

Upvotes: 10

dpercy
dpercy

Reputation: 478

git stash pop does 2 things: git stash apply and git stash drop. If you can undo the drop, using this question and answers, then you'd just have to undo the apply. I'm not sure how to do this, but you might look into git rebase. but adl does.

Upvotes: 1

Related Questions