Find Changes With git log -S (Pickaxe)

Locate commits that introduced or removed a code string.

macOSsearchgitcliLow risk
Run git log -S "text" to list commits whose diff changed the occurrence count of that text.

01Command

Command
$ git log -S "retry" --oneline -- src/

02What it does

Pickaxe search answers 'when did this function or config appear?', which is invaluable when debugging regressions or understanding history. Limiting with a path and -G for regex searches makes it precise and fast on large repositories.

03Risk

RiskLow risk
RequirementsGit 2.20+ (install with Homebrew or Xcode Command Line Tools)
CompatibilitymacOS with Git installed (Homebrew or Xcode Command Line Tools)
!Warning: Pickaxe scans diffs, so very large histories can be slow; narrow by path or date range.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • git-log documentation
    Git · vendor-doc · 2026-09-20
    Evidence: Documents the -S pickaxe option, which finds commits changing the number of matches.

Last verified: 2026-10-13 · Category: Developer

06Related solutions