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:
[alias]
rgrep = !git grep
Alternatively, you can use git rev-parse --show-toplevelto get the root directory, which you can then pass git grepin as the basis for a script or alias:
git grep $pattern -- `git rev-parse --show-toplevel`