I reach for git grep before plain grep inside a repository. By default it looks only at tracked files in the working tree, so node_modules, build output and other junk stay out of the results without a single exclude flag.
git grep -n -p TODO
-n adds line numbers. -p (--show-function) is the nice one: above each match git prints the line with the name of the function it sits in, so you see straight away that this TODO is in parse_config and not in some test helper. -W goes further and prints the whole function around the match. Add -i to ignore case.
It can search old versions too, without a checkout. Put a tag or commit after the pattern:
git grep -n "max_retries" v1.0
That searches the files as they were in v1.0. I use that kind of check to see when a setting was still called something else.
Caveat: new files you haven’t added yet are invisible to it, because they’re not tracked. Add --untracked to include them. The docs note that this flag can’t be combined with --recurse-submodules.
Further reading: git-grep documentation