Normally when I issue git grep, it will only search the current directory and below, for instance
$ cat A
1
$ cd d
$ cat B
1
$ git grep 1
B:1
$ cd ..;git grep 1
A:1
B:1
How can I tell git grep “search the entire tree, no matter the current working directory I’m in”?
Git aliases that run shell commands are always executed in the top level directory (see the
git configman page), so you can add this to your.gitconfigfile:Alternatively, you could use
git rev-parse --show-toplevelto get the root directory, which you could then pass togit grepas the basis of a script or alias: