DEV Community

Discussion on: 10 insanely useful Git commands you wish existed – and their alternatives

Collapse
 
cameronblandford profile image
Cameron • Edited

Thanks for this great post, I learned a lot! It’s worth noting that git stash apply does the same thing as git stash pop except it’s non-destructive and doesn’t delete the stashed changes from your stash history! That way if you mess up while re-adding changes from the stash (which has happened to me before, especially during a stash merge conflict), you can easily re-implement the same stashes changes! Definitely would recommend as a preferred command.

Collapse
 
eyarz profile image
Eyar Zilberman

This is why I love the DEV community - you learn something new every day...

Thanks to you, this is what I learned today:
git stash pop is git stash apply && git stash drop. git stash pop applies the top stash and removes it, while git stash apply does the same but leaves the stash in the stack.

Therefore, it is recommended to use $ git stash apply in this use case - I will update the post :)