A developer commits a .env file "just for a quick test". The commit gets amended, the file is deleted in the next commit, and everyone moves on. Six weeks later, the AWS access key inside that blob is still perfectly readable in git log -p , and it has already been indexed by three bots scanning public GitHub pushes.
This article walks through both halves of the problem: blocking future leaks with gitleaks in pre-commit and CI, and cleaning up a repository that is already compromised — revocation, rotation, and history rewriting with git filter-repo . No prior security tooling experience is assumed.
Why a leaked secret in Git is worse than it looks
Git is an append-only object database. Deleting a file in a new commit does not delete the blob; it just stops referencing it from the tip of the branch.…