What do you do after a secret is committed to Git?
IntermediateProductionSecrets and Credentials
Answer
- Revoke or rotate the secret immediately; this is the only real fix.
- Check provider audit logs (CloudTrail, GitHub audit log) for use during the exposure window.
- Optionally rewrite history with
git filter-repoand force-push, then have everyone re-clone; forks and caches may still hold it. - Add a scanner rule and push protection to prevent recurrence.
- Write a short post-incident note: how it got there, how long it was exposed.
More on Secrets and Credentials
Why are long-lived credentials in CI a problem, and what is the modern alternative?BeginnerHow do you manage application secrets from build to runtime?IntermediateHow do you store secrets in Git safely for GitOps?IntermediateHow do you detect secrets committed to a repo?BeginnerHow do you use HashiCorp Vault with CI/CD?AdvancedHow do you rotate a credential used by dozens of pipelines without downtime?Advanced