Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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