Download the latest version from the site: https://rtyley.github.io/bfg-repo-cleaner/
Create a folder:
mkdir clean-repo
Inside the this folder create a txt file with the password o sensitive data you want to revove
cd clean-repo
echo "mySuperPassword" > passsword.txt
clone a fresh copy of your repo, using the --mirror
flag:
git clone --mirror git://example.com/some-repo.git
This is a bare repo, which means your normal files won't be visible, but it is a full copy of the Git database of your repository, and at this point you should make a backup of it to ensure you don't lose anything
.
Now you can run the BFG to clean your repository up:
java -jar bfg-1.14.0.jar --replace-text passwords.txt some-repo.git
Access your repo folder to run the follow command:
cd some-repo.git
git reflog expire --expire=now --all
git gc --prune=now --aggressive
git push
All you sensitive data on your commit history was replace with ***REMOVED***