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!

  1. Create a .gitignore file. Add the sensitive folders to it.
  2. Make sure the most recent commit does NOT have any of the bad folders!!
git rm –r –cached gallery

git rm –r –cached ‘–gallery’

git commit –m "Remove sensitive folders.";

git push

Then, clean the remote and its history.

  1. Install the JAVA runtime environment (BFG requires it.)
  2. Download BFG: http://rtyley.github.io/bfg-repo-cleaner/

  • Open PowerShell at the desktop.
  • Then run these commands:
  • git clone --mirror https://github.com/bigfont/my-repository.git

    java -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