Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to preview stash contents in git?

Tags:

git

git-stash

I often put work away for later, then other stuff comes along, and a few weeks later, I want to inspect the stash, and find out what changes it would make if I applied it to working tree in its current state.

I know I can do a git diff on the stash, but this shows me all the differences between the working tree and the stash, whereas I'm just interested to know what the stash apply is going to change.

How can I do this?

like image 764
Benjol Avatar asked Aug 26 '10 09:08

Benjol


People also ask

How do I view stash entries?

One you have identified the entry in which you are interested, you likely want to see what is in that stash. This is where the git stash show command comes in. This will display a summary of file changes in the stash.

How do I check my stash diff?

From the git stash manpages: By default, the command shows the diffstat, but it will accept any format known to git diff (e.g., git stash show -p stash@{1} to view the second most recent stash in patch form). stash@{0} is the default; you only need an argument if you want to look at previous stashes.

How do I pop a particular stash?

To pop a specific stash in git, you can use the git stash apply command followed by the stash@{NUMBER} command. command. It will show the list of stashes you have saved.

What does git stash show do?

git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on.


2 Answers

git stash show will show you the files that changed in your most recent stash. You can add the -p option to show the diff.

git stash show -p 

If the stash you are interested in is not the most recent one, then add the name of the stash to the end of the command:

git stash show -p stash@{2} 
like image 134
Jlew Avatar answered Sep 22 '22 15:09

Jlew


To view a current list of stash:

git stash list 

You'll see a list like this:

stash@{0}: WIP on ... stash@{1}: ... stash@{2}: ... ... 

To view diff on any of those stashes:

git stash show -p stash@{n} 
like image 21
segfault Avatar answered Sep 19 '22 15:09

segfault