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.
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:
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.