0

I have a large file that was committed at the origin of multiple branches. This file was later modified, moved or removed from the branches. The problem is that the file is too big for GitHub, so I want to remove it (all versions of it) from everywhere. How can this be done?

I have seen a recipe for amending a merge containing such a file (https://stackoverflow.com/a/308684/42973), or a method for removing a file from (apparently) a single branch (https://stackoverflow.com/a/5563603/42973), but they do not apply or work in this case.

Community
  • 1
  • 1
Eric O. Lebigot
  • 91,433
  • 48
  • 218
  • 260
  • You're probably looking for `git filter-branch`, here. – jub0bs Nov 20 '14 at 10:04
  • @Jubobs: This is indeed what is used in the answer I linked to. However, that answer did not work for me (I guess because the conditions are like I describe). So, yes, it looks like `filter-branch` is a good idea, but I am curious about how to use it in my case. – Eric O. Lebigot Nov 20 '14 at 11:20

1 Answers1

1

Use the BFG Repo-Cleaner, a simpler, faster alternative to git-filter-branch specifically designed for removing unwanted files from Git history.

You should carefully follow the usage instructions, but the core part is just this:

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

Any files over 50MB in size (that aren't in your latest commit) will be removed from your Git repository's history.

The BFG is typically at least 10-50x faster than running git-filter-branch, and generally easier to use.

Full disclosure: I'm the author of the BFG Repo-Cleaner.

Roberto Tyley
  • 24,513
  • 11
  • 72
  • 101