Create a gist now

Instantly share code, notes, and snippets.

anonymous / Secret
Created Sep 19, 2011

What would you like to do?
Search all branches in a git repository for a filename with a specific regex
# original credit to
# usage: " <regex>"
#LOC=refs/heads # to search local branches only
for branch in `git for-each-ref --format="%(refname)" $LOC`; do
found=$(git ls-tree -r --name-only $branch | grep "$1")
if [ $? -eq 0 ]; then
echo ${branch#$LOC/}:; echo " $found"

redheli commented Oct 2, 2013

it works. Thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment