Is it possible to search all of my Git remote branches for specific file contents (not just a file, but contents within them)?
My remotes are on GitHub, in case that
You can try this:
git grep 'search-string' $(git ls-remote . 'refs/remotes/*' | cut -f 2)
That will search all remote branches for search-string
. Since the symbolic reference HEAD
is mirrored, you may end up searching the same commit twice. Hopefully that's not an issue. If so, you can filter it out with:
git grep 'search-string' \
$(git ls-remote . 'refs/remotes/*' | grep -v HEAD | cut -f 2)
If you need to dig through your entire history, you can also try:
git grep 'search-string' $(git rev-list --all)
Assuming you are tracking all remote branches, this will search it in all commits:
git log --all -p | grep 'search-string'
To track all remote branches:
for remote in `git branch -r`; do git branch --track $remote; done