BFG Repo-Cleaner

BFG Repo-Cleaner is a good tool to clean up a Git repository before sharing.

Removes large or troublesome blobs like git-filter-branch does, but faster. And written in Scala.


    $ bfg --strip-blobs-bigger-than 100M --replace-text banned.txt repo.git

Replace all passwords and listed in a file (prefix lines ‘regex:’ or ‘glob:’ if required) with


     ***REMOVED***

wherever they occur in your repository :


    $ bfg <strong>--replace-text passwords.txt</strong>  my-repo.git

Delete all files named ‘id_rsa’ or ‘id_dsa’ :

    $ bfg <strong>--delete-files id_{dsa,rsa}</strong>  my-repo.git

Using BFG on Windows:

  java -jar bfg.jar $*

PASSWORD        # Replaces PASSWORD with ***REMOVED***
PASSWORD==>TEST # Replaces PASSWORD with TEST
PASSWORD==>     # Replaces PASSWORD with blank
# You can use Regular Expressions also


bfg –replace-text replace.txt


git reflog expire –expire=now –all && git gc –prune=now — aggressive

git push                   # -f may be needed

Notes:

Resources: