Created
May 25, 2026 20:20
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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