AI & Agents

How-To: Scan Your Git History for Live Keys Before You Push

Leave a comment

The Gitee scan found 26,400 working keys, many in old commits. Before anything of mine goes public, this is the check I run.

1. Scan the whole history with TruffleHog

trufflehog git file://. --results=verified

That walks every commit and only reports keys that still work.

2. Add a fast pre-commit check with Gitleaks

gitleaks git -v                       # scan history
gitleaks git --pre-commit --staged -v # check what you're about to commit

Wire that second line into .git/hooks/pre-commit or the pre-commit framework.

3. If you find one

Rotate the key first. Rewriting history comes second, and it never un-leaks anything already pushed. Then move secrets into env files that are listed in .gitignore, or into a vault, so agents never see raw keys.

Review before you run anything: read the docs yourself, back up your config, and try it somewhere you can afford to break first.

God Bless, and May the Source Be with You!

References & Further Reading

Subscribe (RSS) Follow AI & Agents via RSS

Leave a note

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.