2

I have a repository in which there is a "Trash" folder with a lot of trash files (previous developer wanted to store them for whatever reason). I want to completely remove them from repo, as they take almost 1.5 GB of space. I already saw such problem: Remove folder and its contents from git/GitHub's history but mine is a little bit different: initially "Trash" files were somewhere else, so I need to:

  1. Get all files from "Trash"
  2. Find all references of them in history
  3. Remove every notion of them from history

How can it be done?

ckruczek
  • 2,361
  • 2
  • 20
  • 23
Andrei Andreev
  • 743
  • 1
  • 7
  • 16
  • Not entirely clear: Do you just want to delete the Trash folder and all the files therein from history, or do you also want to remove the files that were moved to trash _before_ they were moved to trash? In the latter case, checking out an older version might leave you with an incomplete codebase. – tobias_k Jul 10 '17 at 14:30
  • (Yes, latter case) Agree, I'll lose stablility of previous commits, so I have 3 options: a) forget about history, create a fresh new repo and make one big "Initial commit", b) use BFG to remove just big files from history, c) somehow completely purge files from "Trash". I chose latter one. – Andrei Andreev Jul 10 '17 at 14:45

1 Answers1

4

you can use BFG Repo-Cleaner

The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history

Faster : 10 - 720x faster

Simpler : The BFG isn't particularily clever, but is focused on making the above tasks easy

examples:

Delete folder named 'myfolder':

bfg --delete-folders myfolder  my-repo.git

Delete all files named 'id_rsa' or 'id_dsa' :

bfg --delete-files id_{dsa,rsa}  my-repo.git

Remove all blobs bigger than 50 megabytes :

bfg --strip-blobs-bigger-than 50M  my-repo.git

Remove all folders or files named '.git' - a reserved filename in Git. These often become a problem when migrating to Git from other source-control systems like Mercurial :

bfg --delete-folders .git --delete-files .git  --no-blob-protection  my-repo.git
Ebrahim Poursadeqi
  • 1,776
  • 2
  • 17
  • 27