LoginSignup
26
11

More than 5 years have passed since last update.

git-grepで特定のディレクトリを除外する

Last updated at Posted at 2017-01-12

git-grep には --exclude オプションがないので ls-files や パイプラインで除外するしかないと思っていたのだけど、指定するパスにglobのワルドカードパターンで否定条件を渡せることを知った。

# Vendor/ ディレクトリは除外したい
git grep amazon -- ':!Vendor/' .

ダブルダッシュは -- 以後をオプション(--hogeとか)でなくコマンドの引数テキストになることを明示していて、そこにワイルドカードの既述を食わせるために必要らしい。

参考

How to exclude certain directories/files from git grep search - Stack Overflow
で知った。
どの環境のシェルやgrepでも動くのかはまだ知らない。

26
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
11