How to use gitโ€™s search tool

Help

$ git grep --help
       git-grep - Print lines matching a pattern
...

Resources

Examples

Looks for time_t in all tracked .c and .h files in the working directory and its subdirectories.

$ git grep 'time_t' -- '*.[ch]'

Looks for a line that has #define and either MAX_PATH or PATH_MAX.

$ git grep -e '#define' --and \( -e MAX_PATH -e PATH_MAX \)

Looks for a line that has NODE or Unexpected in files that have lines that match both.

git grep --all-match -e NODE -e Unexpected

Looks for solution, excluding files in Documentation.

$ git grep solution -- :^Documentation