あなたはgit log
に-S
と--pretty
フラグを組み合わせたいです。 git log
manページから
、-S
つるはし検索:
-S<string>
Look for differences that introduce or remove an instance of <string>. Note that this is different than the string simply appearing in diff output;
see the pickaxe entry in gitdiffcore(7) for more details.
このフラグは、特定の文字列に対するすべての変更を探します。 Using an example from another SO answer,git log -g -Ssearch_for_this
は「search_for_this」へのすべての変更の履歴を検索します。
は、より良い結果を得るために--pretty
とそれを組み合わせます。たとえば、このコマンドは 'foo'の変更履歴を検索し、短縮されたハッシュ、著者、2つのダッシュ、メッセージの最初の行、2つのダッシュ、日付を返します。
$ git log -Sfoo --pretty=format:'%h %an -- %s -- %ad'
bc34134 Sally Developer -- Fixed all bugs and made all clients happy forever -- Tue Jan 31 17:41:17 2025 -0500
あなたは、改訂レベルごとの情報を得るために責任を負う/注釈を付けることができます。 「誰がラインを変えたか」は、一度あなたが複数のリビジョンを持ち込むと、あいまいな質問になり始めます。 –
そのポイントは何ですか? –
@Tomasz:特定の行の履歴を検索することは、特にバグがコードベースにどれくらい存在しているのか、特定の関数に触れているのかを見たいときには非常に便利です。 – Christopher