Skip to content

Instantly share code, notes, and snippets.

@copyleftdev
Created May 25, 2026 20:20
Show Gist options
  • Select an option

  • Save copyleftdev/fca15952d2f5caa78f8c8fa8293f1835 to your computer and use it in GitHub Desktop.

Select an option

Save copyleftdev/fca15952d2f5caa78f8c8fa8293f1835 to your computer and use it in GitHub Desktop.
git log -S — the pickaxe: find when a string was added or removed
# git log -S — the pickaxe
# Find commits where a specific string's count in a file changed.
# Searches diff content, not commit messages.
# When was this secret added or removed?
git log -S "API_SECRET" --all --oneline
# See the full diff for each match:
git log -S "API_SECRET" -p
# Find by literal secret value (one result — the commit that introduced it):
git log -S "xK9-hunter2-prod-8821" --oneline --all
# Regex variant (-G accepts a pattern):
git log -G "API_SECRET\s*=" --oneline
# Even after the secret is deleted from HEAD, it lives in history.
# Finding it here is why rotation matters, not just deletion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment