📝 Edit on GitHub
Git-grep cheatsheet
How to use git’s search tool
Resources
- git-grep Documentation
- Git - Searching tutorial.
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