Skip to content

Looking for files in other branches

heffjos edited this page Aug 21, 2012 · 1 revision
for branch in `git for-each-ref --format="%(refname)" refs/remotes/universe`; do
  echo $branch :; git ls-tree -r --name-only $branch | grep '<foo>'
done

The above will print out each branch in the remote universe and the directory path of the file in each branch. This code was taken from StackOverflow: http://stackoverflow.com/questions/372506/how-can-i-search-git-branches-for-a-file-or-directory

Clone this wiki locally