When I want to quickly search for something in the code I use GitHub search page. With the prefixes like
org:<organization-name> it's really great and I have even defined custom browser search engines for different organizations. Then I can simply write something like
org "127.0.0.1" into my browser and it finds all localhosts in my
org in all repositories.
The problem is that GitHub indexes only the main branch (whatever you name it). But when there are more branches with active development I want to search even those. And that's why I have a simple batch script to achieve that. Now I can go to any local repo and run
git-search "127.0.0.1" or
git-search "\b_source\b" and I get all unique lines matching the RE pattern. Here is the magic script to do that.
@echo off rem https://stackoverflow.com/questions/7151311/using-git-how-could-i-search-for-a-string-across-all-branches git fetch origin git remote prune origin git branch --remote | grep -v " -> " | xargs git grep %* | cut --delimiter=":" --fields=2,3 | uniq | grep --color=always -E %*