Remove sensitive folders (e.g. a private image gallery) from a remote repository with BFG.
BFG helped remove sensitive images from a remote repository. The bad folders were gallery and –gallery. It could also work with App_Data and Media (e.g. in Orchard).
First, make a clean commit.
This is vital!
- Create a .gitignore file. Add the sensitive folders to it.
- Make sure the most recent commit does NOT have any of the bad folders!!
git rm –r –cached gallerygit rm –r –cached ‘–gallery’
git commit –m "Remove sensitive folders.";
git push
Then, clean the remote and its history.
- Install the JAVA runtime environment (BFG requires it.)
- Download BFG: http://rtyley.github.io/bfg-repo-cleaner/
- Then rename the download file to bfg.jar
- Then copy-paste it to the desktop
- Open PowerShell at the desktop.
- Then run these commands:
git clone --mirror https://github.com/bigfont/my-repository.gitjava -jar .\bfg.jar --delete-folders '{-gallery,gallery}' .\my-repository.git
cd .\my-repository.git
git reflog expire --expire=now –all
git gc --prune=now –aggressive
git push