After rotating the leaked key, you must purge it from repository history. How?
AdvancedScenarioSecrets, Signing and Security
Answer
Situation read → The key is dead, but history still shows it, and scanners and forks keep flagging it.
What I'd do →
- Fresh mirror clone:
git clone --mirror [email protected]:org/app.git. - Replace the string everywhere:
echo 'AKIAXXXXXXXXXXXXXXXX==>REMOVED' > replacements.txt
git filter-repo --replace-text replacements.txt
git push --force --mirror
- Ask all developers to re-clone (not pull), and close or recreate open PRs.
- Contact GitHub Support to purge cached views and
refs/pull/*references if needed; check forks.
Why → Rewriting changes all downstream SHAs, so coordination matters. Old clones can re-introduce the secret on push.
Interview tip → BFG is an alternative, but git filter-repo is the tool Git itself recommends.
More on Secrets, Signing and Security
A developer pushed an AWS access key to a public repo 10 minutes ago. What is your first move?BeginnerA push is rejected: "GH013: Repository rule violations found ... Push cannot contain secrets". What do you do?IntermediateSecret scanning alerts have piled up, and many look like false positives or old test credentials.IntermediateYou must set up signed commits on your laptop. Which method do you pick?BeginnerYour GPG signing key expires next week. What is the correct way to handle it?IntermediateA release bot pushes commits, and branch rules require signed commits. How do you handle it?Intermediate