Skip to content

Instantly share code, notes, and snippets.

@handyman5
Created October 25, 2011 16:28
Show Gist options
  • Save handyman5/1313342 to your computer and use it in GitHub Desktop.
Save handyman5/1313342 to your computer and use it in GitHub Desktop.
Search for a filename in all git branches
#!/bin/bash
#LOC=refs/remotes/origin
LOC=refs/heads
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/}:
for f in $found; do
echo " $f"
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment