-
-
Save hartym/2584767 to your computer and use it in GitHub Desktop.
git stash grep (bash)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stashgrep() { | |
for i in `git stash list | awk -F ':' '{print $1}'`; 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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you switch to Tommy's suggestion, you also need to add
IFS=$'\n'
, so the function would be: