How to git grep only a set of file extensions

前端 未结 2 1543
孤独总比滥情好
孤独总比滥情好 2021-02-13 02:06

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:

         


        
2条回答
  •  囚心锁ツ
    2021-02-13 02:58

    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.

提交回复
热议问题