Git · Senior · Question 12 of 76
How do you remove a leaked secret from a repository's whole history?
- 1Delete the file in a new commit and push it to
main - 2Run
git gc --aggressiveon the server repository - ✓Correct answer: Rewrite with
filter-repo, force-push, rotate the secret
Explanation
filter-repo (or BFG) rewrites every commit; all collaborators must re-clone, and hosting caches and forks may keep copies. That's why rotating the secret is the step that actually matters.