Dev.to
7/24/2026

The original title is "Oops, I Committed a Secret: A Calm Guide to Scrubbing Git History"
Original: Oops, I Committed a Secret: A Calm Guide to Scrubbing Git History
Short summary
A practical guide to scrubbing secrets from Git history, starting with the non-negotiable step of rotating any leaked key before touching history. Covers quick fixes for un-pushed commits using git amend, and deep cleaning with git filter-repo or BFG Repo-Cleaner for secrets already in remote history. Recommends pre-commit scanners like gitleaks and secret managers to prevent future leaks.
- •Rotate leaked secrets first — this is the only non-negotiable step
- •Use git filter-repo or BFG for secrets already in pushed history, then force-push and notify collaborators
- •Prevent future leaks with .gitignore, secret managers, and gitleaks pre-commit hooks
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



