简体   繁体   中英

How to remove a file at the origin of multiple branches from the git history?

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM