- clone a repo you want to clean, change directory to newly cloned folder
- create a file containing all the lines/secrets you want to remove
- run java -jar ~/Downloads/bfg-1.14.0.jar --replace-text /tmp/.env .
- run git reflog expire --expire=now --all && git gc --prune=now --aggressive
- foreach branch that contains the changes, do git checkout branchName && git push --force
After force push, the offending lines will be replaced with "***REMOVED***" line.