Pickaxe — search across time, not just space
Grep searches the working tree — what exists right now. git log -S and git log -G, the "pickaxe" flags, search across all of history: which commits introduced or removed this string anywhere in any file. The first time you use this on a real "did we ever ship feature X?" or "when did this magic constant first appear?" question, it feels like cheating. Once you internalize that history is searchable, ad-hoc archaeology becomes a few-second answer.
-S "term" finds commits where the count of that exact term changed — i.e., the term was added or removed. Best for tracking specific identifiers, function names, environment variables, or magic strings. -G "regex" finds commits whose diff matches the regex anywhere in changed lines. Looser; good for patterns like "any commit that touched a JSON config." Both default to searching all of history; combine with -- <path> to scope to a directory or file.
The flag that completes the workflow is -p — show the actual diffs of matching commits inline. git log -p -S "OAUTH_ENABLED" shows you the commits where OAUTH_ENABLED entered the codebase, plus the surrounding context of what else changed at the same time. Add --all to search every branch, not just current; add --source to label which ref each match came from.
For the structural cousin: git log --grep="auth" searches commit messages, not diffs. Useful when you remember roughly what the commit said. --author="Pippa" filters by author. --since="2026-04-01" --until="2026-05-01" filters by date range. Pickaxe + grep + author + date filters layer naturally — find every commit by a specific author that touched a specific identifier in the last quarter, in one query.