Git: How to look at the stash

Updated . Posted . Visible to the public.

Browsing the git stash is a bit tricky. Here is how to see the changes without applying them:

git command on the console

The following will give you the diff of the topmost stash item:

git stash show -u

But what about other items on the stash?
Well, you can list them like this:

$ git stash list
stash@{0}: WIP on feature/foo
stash@{1}: WIP on feature/bar
stash@{2}: WIP on fix/baz

All those stashed changes have their own reference (like branch names) that you can look at, like stash@{0}, stash@{1}, etc.
Above, we looked at stash@{0} which is the default for stash actions.

So, to look at the second item, you can now say:

git stash show stash@{1} -u

Using tig

To show all items in the stash (you can see the diff by pressing Enter on a stash):

tig stash

As explained above, each item on the stash has its reference. You can use that for tig Show archive.org snapshot just as well:

tig stash@{2}

Using gitg

Gitg will show you items from the stash at the top of the history. Nothing to do except selecting them. :)

stash items in gitg

Arne Hartherz
Last edit
Jonas Schiele
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2012-09-24 09:33)