git grep by file extensions

后端 未结 3 1384
野的像风
野的像风 2021-01-30 10:18

I know that, if I wanted to grep for a pattern only on files with certain extensions, I could do this:

// searches recursively and matches case insensitively in          


        
相关标签:
3条回答
  • 2021-01-30 10:37

    if you want to search across all branches, you can use the following:

    git log -Sres --all --name-only -- '*.js'
    

    (I see you specify git grep; to me the approach here seems simpler and easier to remember--more like other operations I need commonly.)

    0 讨论(0)
  • 2021-01-30 10:40

    Yes, for example:

    git grep res -- '*.js'
    
    0 讨论(0)
  • 2021-01-30 10:42

    Try doing this :

    find . -type f -iname '*.js' -exec grep -i 'pattern' {} +
    
    0 讨论(0)
提交回复
热议问题