[Git] Find commits that changed the count of a string

Created on November 30, 2026

Use git log -S to find commits where the number of occurrences of a string in a file changed. The example searches the history for additions or removals of Hello World.

git log -S "Hello World"

Use git log --grep for commit messages or git log -G for added or removed patch lines matching a regular expression.

Git