Searching for a file in all Git branches

This is one way:

git log --all --name-only --pretty=format: | sort -u | grep _robot.php

Here is a simpler variation on @manojlds's solution: Git can indeed directly consider all the branches (--all), print the names of their modified files (--name-only), and only these names (--pretty=format:).

But Git can also first filter certain file names (regular expression) by putting the file name regular expression after the -- separator:

git log --all --name-only --pretty=format: -- <file_name_regexp> | sort -u

So, you can directly do:

git log --all --name-only --pretty=format: -- _robot.php | sort -u

Tags:

Git

Grep