Using Git, how could I search within all files in all local branches for a given string?
GitHub specific: is it possible to perform the above search across all GitHu
In many cases git rev-list --all can return a huge number of commits, taking forever to scan. If you, instead of searching through every commit on every branch in your repository history, just want to search all branch tips, you can replace it with git show-ref --heads. So in total:
git grep "string" `git show-ref --heads`
or:
git show-ref --heads | xargs git grep "string"
Tip: You can write output in file to view in an editor:
nano ~/history.txt
git show-ref --heads | xargs git grep "search string here" >> ~/history.txt