How to find commits that removed a string?

git log -S'word'

To find commits that removed a string use git log -S'word'. This will show you every commit where the number of occurrences of 'word' changed (was added or removed) and is also called pickaxe search.

The 'word' accepts string literals, not regular expressions. To search regular expressions use -G'regexp' instead of -S'word'

You can add parameter -p to also show the contents of the commits.

Layer 1
Terminal Example
git log -S'Git is awesome'
commit 5596e083501bb9a4b6210eb13ce8577ea359c97c (HEAD -> main)
Author: Tom Ato
Date:   Thu Aug 19 16:24:55 2021 +0200

    Remove 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.

Last modified on November 30, 2021.

You might also like