Is there a way in git to find whether a file is present in multiple branches or not? If so list the branch names. Please provide help on this.
Asked
Active
Viewed 114 times
1
-
possible duplicate of [How can I search Git branches for a file or directory?](http://stackoverflow.com/questions/372506/how-can-i-search-git-branches-for-a-file-or-directory) – Francisco Félix Jul 23 '15 at 06:47
1 Answers
2
You can try to run in each branch this command:
git ls-files | grep YOUR FILE
And see if it appears.
Or you can do a more elaborated script like this:
for i in $(git branch | sed 's/\*//'); do git checkout $i; git ls-files | grep -q YOURFILE ; if [ $? -eq 0 ] ; then echo "File found in branch: $i"; fi; done
Do a loop for each branch and do the same that the previous command.

blashser
- 921
- 6
- 13