How to git grep only a set of file extensions
file-extension, git, grep
Solution
Use:
git grep "MyFunc" -- '*.cpp' '*.h'
The quotes are necessary so that git expands the wildcards rather than the shell. If you omit them, it'll only search files in the current directory, rather than including subdirectories.
Problem
How do you perform a git grep and limit the files checked to a set of files. I would like to be able to grep the contents of .cpp and .h files looking for MyFunc. eg: ``` git grep "MyFunc" -- *.[hc]* ``` However this also matches, .c files and .cs files.