| English | 中文 |
After committing a secret into Git history, the first step is always to revoke and rotate the keys.
Cleaning up history only reduces further exposure; it cannot make an already leaked secret secure again.
Use git filter-repo:
git filter-repo --path path/to/secret-file --invert-paths
Then force push the cleaned history:
git push --force --all
git push --force --tags
History rewriting affects all collaborators; you must notify the team before execution and require everyone to resynchronize the repository.