In brief
git grep searches matching lines within a selected repository scope. With --cached, it can search the index rather than current working files.
Useful to know
git grep searches matching lines within a selected repository scope. With --cached, it can search the index rather than current working files. [1]
This matters when a staged configuration was later edited. Decide whether the pattern is literal text or a regular expression. No match in one view does not establish absence from every revision or untracked file.
Sources
For further detail and to check the information: