I frequently use git stash
and git stash pop
to save and restore changes in my working tree. Yesterday I had some changes in my working tree that I
The accepted answer by Aristotle will show all reachable commits, including non-stash-like commits. To filter out the noise:
git fsck --no-reflog | \
awk '/dangling commit/ {print $3}' | \
xargs git log --no-walk --format="%H" \
--grep="WIP on" --min-parents=3 --max-parents=3
This will only include commits which have exactly 3 parent commits (which a stash will have), and whose message includes "WIP on".
Keep in mind, that if you saved your stash with a message (e.g. git stash save "My newly created stash"
), this will override the default "WIP on..." message.
You can display more information about each commit, e.g. display the commit message, or pass it to git stash show
:
git fsck --no-reflog | \
awk '/dangling commit/ {print $3}' | \
xargs git log --no-walk --format="%H" \
--grep="WIP on" --min-parents=3 --max-parents=3 | \
xargs -n1 -I '{}' bash -c "\
git log -1 --format=medium --color=always '{}'; echo; \
git stash show --color=always '{}'; echo; echo" | \
less -R