First find the reference for the entry you want through looking at the stash:
$ git stash list
stash@{0}: WIP on feature/foo
stash@{1}: WIP on feature/bar
stash@{2}: WIP on fix/baz
Now you can simply use that reference, but curly braces must be escaped:
git stash pop stash@\{1\}
or quoted:
git stash apply "stash@{1}"
Quick reminder to not shoot yourself in the foot:
-
apply
applies the entry to the working directory but will not delete it from the stash -
pop
applies and deletes the entry from the stash (only if there were no conflicts when applying it) -
drop
will only delete and not apply the entry
Running these commands without a reference will use it with the last entry.
Partial stash pop
Sometimes you only want to pop
parts of the stash. Do this the way vice versa:
git stash pop
git stash -p # Now move all the unnecessary parts back into the stash
Show Diff of the stash
To show the code changes of the last (or any other) stash in patch format, use the following command:
git stash show -p
git stash show -p stash@{1} # to view the second most recent entry in patch form
With tig
tig
offers an easy way to browse through the contents of your stash as well: tig stash
. Navigating works as expected.
Posted by Judith Roth to makandra dev (2017-01-17 13:06)