Undo git stash apply

Undo git stash apply

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.

Git stash commands

To un-apply the most recent stash this command is used:

git stash show -p | git apply -R

now to add this as an alias we run this command in the terminal:

git config --global alias.stash-unapply '!git stash show -p | git apply -R'

Now when un-applying is needed we will be able to run:

git stash-unapply