-
-
Save evan-burke/71f3c087070182234f140eeb6a13d2f8 to your computer and use it in GitHub Desktop.
cleaning sensitive data from a repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Start somewhere with Java runtime and a Git command line. Git should be configured with a valid SSH key for the repo. | |
- Create and push a new commit reverting any changes you want to wipe. This is done to ensure the commit is not 'protected'. | |
- Create & cd into temporary dir if you want. | |
- Download .jar file from here - search for 'downloadable jar'. | |
https://rtyley.github.io/bfg-repo-cleaner/ | |
- Clone repo (with github, use ssh URL, not https) with --mirror: | |
git clone --mirror [repo location] | |
- If you want, run bfg without any inputs to see a list of options. | |
java -jar bfg*jar | |
- If you are cleaning passwords, put the passwords in plain text, one per line, in passwords.txt, then do: | |
java -jar bfg*jar --replace-text paswords.txt [repo dir] | |
- Make sure this doesn't warn you about commits not being changed because they're protected. | |
Finally: | |
cd [repo dir] | |
git reflog expire --expire=now --all && git gc --prune=now --aggressive | |
git push | |
Once the push succeeds, you can remove the repo dir and passwords.txt file. | |
Note: github desktop on Windows seemed to have problems pulling the changes after cleaning. You may need to delete and re-clone the repo. | |
And of course, other copies ofthe repo should be re-pulled from origin. | |
More detail here: | |
https://rtyley.github.io/bfg-repo-cleaner/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment