There are some helpful ideas in this gist and discussion thread in this thread and discussion.
First, just make a list of suitable stashes (with or without -i, depending on the case)
git stash list -i -G<regexp>
If you don’t have much to dig, you can simply add -p
to print the corresponding stashs as a whole.
git stash list -i -p -G<regexp>
Having added more features for "real" cases, add to .gitconfig
:
[alias] stashgrep = "!f() { for i in 'git stash list --format=\"%gd\"' ; \ do git stash show -p $i | grep -H --label=\"$i\" \" $@ \" ; done ; }; f"
and then you can invoke git stashgrep
with any grep arguments you like. eg,
git stashgrep -i <regexp>
This differs from some of the answers above in that it adds a stash identifier to show you where each difference came from.
source share