git filter-repo --sensitive-data-removal --invert-paths --path
git filter-repo --sensitive-data-removal --invert-paths --path <file>
Risk: Can lose work
What it does
Rewrites history, for example to wipe a file from every commit. A separate tool you install.
When to use it
After a secret leaked, and only after you rotated the key.
Example
$ git filter-repo --sensitive-data-removal --invert-paths --path .envWipe .env from all history. Every later commit id changes.
$ git filter-repo --sensitive-data-removal --replace-text ../secrets.txtReplace secret text listed in a file, in every commit.
Learn it in: Leaked a key? Rotate first · Official docs