created: 2020-01-17T02:35:48.000Z

git grepで探すファイルの拡張子を指定

こんな感じでできる

$ git grep cache -- '*.java'

git grepでは -- 以降が対象パスの指定となっているので、そこにglobを書くと探索するファイルを指定できる

-- …​ Signals the end of options; the rest of the parameters are limiters.

ちなみにexcludeするときは以下のように書くようだ

$ git grep solution -- :^Documentation

Looks for solution, excluding files in Documentation.

参考

みんなのデータ構造
[ad] みんなのデータ構造
Pat Morin, 堀江 慧 (単行本(ソフトカバー))