0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

git grepのチートシート

Last updated at Posted at 2023-04-29

vim向けのタグファイルの更新作業がウザいので、gitで手軽に検索する。
とりあえず基本パターン:

git grep -n ':errno:' -- '*[ch]'

ワークディレクトリとそのサブディレクトリで追跡されているすべての「*c」または「*h」ファイルで':errno:'を検索し、ファイル名と行番号を表示する。

出力例
c_src/key.c:42:         sprintf(strbuf, "%s:errno:%d\n", __func__, errno);
c_src/key.c:62:         sprintf(strbuf, "%s:errno:%d\n", __func__, errno);

追加オプション

オプション 意味
-w パターンは単語の境界でのみ一致
-i パターンとファイルの大文字と小文字の違いは無視
--full-name プロジェクトの最上位ディレクトリからのパスを含むファイル名を表示
-v 一致しないラインを選択
--no-color カラー出力のハイライトをオフにする
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?