How to see stashed changes using git stash

The command git stash is used to stash the changes in a dirty working directory away.

You can list all stashed change using the command  git stash list,

Every time you stash your working directory, git will save the state of working directory into somethine which mantins history of stash tree. Every time you stash your changes it will be save as a kind of commit in stash tree. All stashed changes are stacked in the order with serial or reference. stash@{0} is the first or top most or recent stash. Every time if you want to refer a particular stash you have to use the it’s reference id something like stash@{3}, stash@{5}… etc

Think of each stash as a separate  commit. These commits are stored and stacked differently and not overlapped with conventional git commit history 

A stash is represented as a commit whose tree records the state of the working directory, and its first parent is the commit at HEAD when the stash was created.

The following command can be used to extract diff of stashed change againest any other stash or commit or branch or HEAD.

  • git stash show
  • git show
  • git diff
  • git difftool

Let’s see, how we can use each of the above mentioned commands.

Command git stash show

The simple command git stash show  gives very brief summary of changes of file, but will not show the diff of changes against current HEAD. Something like,

Something like below

Some times this is not so useful. You may want to see the difference against  current HEAD or any specific commit or current directory.

If you use git stash show along with option -p, It will show all changes.


Check diff against selected stash.

Command git show

The command git-show  is used to see  various types of objects.

The command git-show is not only used to visualize  stash changes, but also used to see one or more objects like blobs, trees, tags and commits. For more information check git-show


To see top most stash difference against  HEAD:

To get diff of of selected stash against HEAD:

See selected complete whole file as if stash is applied  from selected stash:


stash@{0} is the reference of stash. I could be any one of stash@{0}, stash@{1}, stash@{2}… etc.

<file_name>  is the name of the file relative to project/git repository

Command git diff 

The command git-diff  is also one of common command which is used to show changes between commits, commit and working tree, etc.

By default, git diff will show the diff of selected stash against(modified files) current state of repository unless other stash  reference or commit is specified.

To get difference between top most stash stash@{0} and master branch:

Only display the names of file not diff of changes:

See the diff between selected stashes for a selected file:


Command git difftool

The command git-difftool can also be used to find diff between selected stash and selected commit or branch or stash

See the difference between latest two stashes:




Commands which are  useful to extract the diff from selected stash git stash show, git show,  git diff, git difftool . 

See difference using command git stash show,

See the changes in the stash using command git show,

See the difference between latest stash and selected commit using command git diff,





Leave a Reply

Your email address will not be published. Required fields are marked *