How to delete a file from a remote Git repository using BFG Repo Cleaner

  • Make sure you have Java installed.
  • Download the BFG Repo Cleaner JAR file from here and save it somewhere, e.g., D:\BFG
  • Open terminal window and go to D:\BFG
  • Mirror the Git repository that you want to clean, e.g., git clone git@github.com:<git user name>/<some repo>.git.
  • Run java -jar bfg-<version>.jar –delete-files <file name> <some repo>.git
  • Type cd <some repo>.git
  • Type git reflog expire –expire=now –all && git rc –prune=now –aggressive
  • Type git push
  • Type rm -rf <path to file to delete> (on Windows best to delete the file through Windows Explorer)
  • Type git rm –cached <path to file to delete>
  • Type git commit -m “Removed file”
  • Type git push origin –force
Scroll to Top