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?
After that just fire git stash pop again and you get the same stash, that conflicted before. Keep in mind: The stash is safe, however, uncommitted changes in the working directory are of course not. They can get messed up. What I understand is that you can simply cleanup and pop again, but you can't undo it.
Sometimes we may need to undo a git stash apply, maybe we didn't mean to apply it at all or we just applied it to the wrong branch. Update: I've made an easy extension to git that makes this command more easy to remember, i call it gitUndo. With that extension all you need run is: git undo stash-apply.
When a developer uses the git stash apply command, the most recently saved stash overwrites files in the current working tree but leaves the stash history alone. In contrast, the pop command restores files but then deletes the applied stash.
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?
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 . but adl does.git rebase
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With