This is a thing that you can do to clean up your local git repo AFTER doing a commit and before pushing to origin. PREWORK 1. Download BFG.jar https://rtyley.github.io/bfg-repo-cleaner/ https://repo1.maven.org/maven2/com/madgag/bfg/1.13.0/bfg-1.13.0.jar 2. Create directory structure mkdir - ~/.binaries/ p 3. Move bfg in to place and chmod it mv bfg .jar ~/.binaries/ && chmod ~/.binaries/bfg .jar -1.13 .0 777 -1.13 .0 4. setup BASH_PROFILE ' bfg= ' >> ~ >> ~ ' bfg= ' >> ~ >> ~ echo alias "java -jar ~/.binaries/bfg-1.13.0.jar" /.bash_profile echo "export PATH=/Users/$(whoami)/.binaries:$PATH" /.bash_profile echo alias "java -jar ~/.binaries/bfg-1.13.0.jar" /.bash_profile echo "export PATH=/Users/$(whoami)/.binaries:$PATH" /.bash_profile 5. source it ~/.bash_profile source Cleaning repo with BFG Now what do we do. I will create a new folder, and then create a git repo in that folder. This would be the same as doing a git clone... mkdir testing-bfg cd testing-bfg/ git init Now I am going to make a file and add some things to it vi README.md PASSWORD=my_password AWS_TOKEN=1234 # do things # do things that are bad add it to my git repo git add README.md make a commit to the repo for the file git commit - -m a "I did an initial commit and it is bad" I am going to attempt to push to master, or don't when I realize I did a bad thing origin master *** pre-receive hook fires stops me from so the fails. git push and pushing, push OR I don't push, but the commit is already in my history, I need to clean it. This is how you fix it. In order for BFG to run properly you cannot run it from the source of your git repo, you need to be at least out by one folder. cd ../ vi ~/my-mess AWS_TOKEN=X1V34 PASSWORD= #this file is now located at your home folder as denoted by the ~/ thingy #my-mess file # these are the strings that you want out of your repo and commit history Now we have our dirty git repo located at . testing-bfg We also have a text file with the "things we want to remove from the repo" that is located at ~/my-mess We are going to run the bfg command which is aliased to but you could also do this without the alias, bfg java -jar bfg-1.13.0.jar The is telling bfg to rewrite my current history in all my branches and make clean. --no-blob-protection bfg ~ testing-bfg/ --replace-text /my-mess --no-blob-protection Now you will have your file in a "modified" state according to git. This is because your local file still has the BAD words in it, however your commit history does not. Therefore it is considered modified. Now, go through and change your local file to fix your shame and do a new commit and move forward. PROFIT