git filter-repo --path secret.txt --invert-paths

Category: Git - Advanced

git filter-repo --path secret.txt --invert-paths

Strip a file from all of history

Removes the named path from every commit, rewriting all affected hashes, so the file is gone from the entire history. filter-repo is the maintained successor to filter-branch, which the Git project now recommends against. Anyone with a clone of the old history can still retrieve the file, so rotate any exposed secrets.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.