Remove sensitive data from a Git repository

Boris HUISGEN

Sometimes a sensitive file like a key a token or a certificate has been mistakenly added into a git repository. To remove any trace of it a complete pass of the commits is required.
To filter a specific filename, use this git
command:
# git filter-branch --force \
--index-filter 'git rm --cached --ignore-unmatch path/to/file' \
--prune-empty --tag-name-filter cat -- --all
The repository should next be force pushed to any remotes.