how to view git stashes without the need to reset?


git newbie here: I have a list of stashes:

[email protected] MINGW64 ~/phuber/magic (master)
$ git stash list
[email protected]{0}: On master: 30 or 31
[email protected]{1}: On master: music
[email protected]{2}: On master: this party

I would like to see each stash, so I do:

$ git stash apply [email protected]{0}

works great! I can see what stash#0; now I wish to move to stash#1, in order to do so I have to clear everything so I do:

$ git reset --hard

and then

$ git stash apply [email protected]{1}

I’m quite sure my process is somewhat wrong, is there a better way without the need of git reset?


You can git checkout a stash:

git checkout [email protected]{0}

And when you’re done inspecting it, switch back to your branch:

git checkout main

(Or whichever branch name is appropriate.)

Since a stash entry is just a commit reference, you can also use git worktree to check out the stash in a different directory:

git worktree add ../checked-out-stash [email protected]{0}

When you’re done:

git worktree remove ../checked-out-stash

Answered By – larsks

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published