-
-
Save hartym/2584767 to your computer and use it in GitHub Desktop.
stashgrep() { | |
for i in `git stash list | awk -F ':' '{print $1}'`; do | |
git stash show -p $i | grep -H --label="$i" "$1" | |
done | |
} |
If you switch to Tommy's suggestion, you also need to add IFS=$'\n'
, so the function would be:
stashgrep() {
IFS=$'\n'
for i in `git stash list --format="%gd"`; do
git stash show -p $i | grep -H --label="$i" "$1"
done
}
The code below is quite convenient, it searches across all stashes files containing "plist" and non-case sensitive "basic" in the filename. any change made to a file passing that is concatenated into test.txt then opened.
for sha in $(git rev-list -g stash); do git ls-tree -r $sha:; done | grep plist | grep basic -i | cut -f 1 | cut -d" " -f 3 | sort | uniq | xargs git show > test.txt; open test.txt
git stash list -G<regex>
is all you need.
list [<options>]
...
The command takes options applicable to the git log command to control what is shown and how. See git-log.
-G<regex>
Look for differences whose patch text contains added/removed lines that match <regex>.
@unthought Beautiful. Thanks so much for this.
git stash list --format="%gd" instead of
git stash list | awk -F ':' '{print $1}'