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?
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.
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.
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.
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.
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}
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}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With