Advertisement
Advertisement


Undo a git stash


Question

I just did a stash in a project that I haven't commit. Is there a way to go back to the state before I stashed? How could I do this? I've closed the terminal and my laptop is shut down. I've done some researched and it seems there's no way to do this.

2012/10/11
1
352
10/11/2012 5:45:17 PM

Accepted Answer

You can just run:

git stash pop

and it will unstash your changes.

If you want to preserve the state of files (staged vs. working), use

git stash apply --index
2016/05/02
687
5/2/2016 6:44:51 PM

git stash list to list your stashed changes.

git stash show to see what n is in the below commands.

git stash apply to apply the most recent stash.

git stash apply [email protected]{n} to apply an older stash.

http://git-scm.com/book/en/Git-Tools-Stashing

2016/10/25

This will also restore the staging directory:

git stash apply --index
2013/09/10