Help us understand the problem. What is going on with this article?

Gitの過去コミットから検索するには

More than 1 year has passed since last update.

過去コミットから検索する

チェックアウトしているブランチで

git rev-list HEAD | xargs git grep '検索文字列'

ブランチ指定

git rev-list ブランチ名 | xargs git grep '検索文字列'

全ブランチから

git rev-list --all | xargs git grep '検索文字列'

オプション指定

正規表現

git rev-list --all | xargs git grep -e '正規表現'

and,or,not条件

複数キーワードでAND,OR,NOT検索したい場合、

git rev-list --all | xargs git grep -e '検索文字列1' --and -e '検索文字列2'

これで、2つの検索文字列を同時に含む行が出力されます。
--or, --not も一緒に使えます。

前後行出力指定

検索文字列を含む前後10行を表示したい場合。

git rev-list --all | xargs git grep -10 '検索文字列'

見やすくしてみる

ファイル名を先頭に出力して、各行に行番号を出力する。

git rev-list --all | xargs git grep --heading --line-number -10 '検索文字列'
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away