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.

参考

Interface(インターフェース) 2023年 07 月号
[ad] Interface(インターフェース) 2023年 07 月号
Interface編集部 (雑誌)