Walk through purging a leaked secret from a 5 GB repo with 200 contributors.
AdvancedProductionSecurity: secrets, signing, access and supply chain
Answer
Rotate first. Announce a freeze, take a mirror backup, run git filter-repo --replace-text on a fresh mirror clone, push all branches and tags with force (temporarily lifting protection through the ruleset bypass), then contact GitHub support to remove cached PR refs (refs/pull/*) and dangling views. Everyone must re-clone because old clones can reintroduce the secret on the next push. Forks and local clones outside your control still hold it, which is why rotation matters.
git clone --mirror [email protected]:org/app.git && cd app.git
git filter-repo --replace-text ../replacements.txt
git push --force --mirror
More on Security: secrets, signing, access and supply chain
What are the first things you do when a secret is committed to a repo?BeginnerHow do you prevent secrets from entering the repo in the first place?IntermediateWhy use OIDC federation for cloud credentials from GitHub Actions instead of stored keys?IntermediateWhat is your policy on signed commits and how do you enforce it?IntermediateWhat do signed commits not protect against, and what supply chain controls complement them?AdvancedWhy pin third-party GitHub Actions to a commit SHA?Intermediate