Revoke/rotate secret first
# rotate credentials in provider consoleDestructiveScan for remaining leaks
git grep -n '<secret-pattern>'Rewrite history
git filter-repo --path <file> --invert-pathsDestructiveForce push rewritten refs
git push --force --allDestructive
Notes
- Secret rotation is the first priority; history rewrite is second.
- Coordinate with the team before force-pushing rewritten history.
Related commands: git filter-repo, git push --force-with-lease, git reflog
Related workflows: Remove sensitive files from Git history