Read more

Git: How to look at the stash

Arne Hartherz
September 24, 2012Software engineer at makandra GmbH

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

git command on the console

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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 Show archive.org snapshot will show you items from the stash at the top of the history. Nothing to do except selecting them. :)

stash items in gitg

Posted by Arne Hartherz to makandra dev (2012-09-24 11:33)