git grep -n 'password' $(git rev-list --all) -- '*.py'

Category: Git - Advanced

git grep -n 'password' $(git rev-list --all) -- '*.py'

Search every commit for a pattern

Expands git rev-list --all into every commit hash and greps each one's tree, turning git grep into a whole-history search. It is how you hunt for secrets or deleted code across all time. Expect slow runs on large repositories.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.