How to find commits that changed lines with a keyword?
git log -G'regex'
To find commits that changed lines with a keyword use git log -G'regex'
, where 'regex' accepts regular expressions. This will show you every commit where the patch text contains added/removed lines that match 'regex'.
You can add parameter -p to also show the contents of the commits.
git log -G'Git is awesome'
commit 5596e083501bb9a4b6210eb13ce8577ea359c97c (HEAD -> main)
Author: Tom Ato
Date: Thu Aug 19 16:24:55 2021 +0200
Remove git text
commit 7a475a5aecc8ba69b66d6a5951fd76022f754d8f
Author: Tom Ato
Date: Thu Aug 19 16:24:38 2021 +0200
Add ! after git text
commit dee17befc06e8115fbcd66b0e05aef47353e236b
Author: Tom Ato
Date: Thu Aug 19 16:24:26 2021 +0200
Add text
See git log to learn more about it.