如何从Git存储库中的提交历史中删除/删除大文件? [英] How to remove/delete a large file from commit history in Git repository?
问题描述
git commit -a -m ...
和zap,回购臃肿了2.2演出。下一次我做了一些编辑,删除了视频文件,并提交了一切,但是压缩文件仍然存在于版本库中,历史上。 我知道我可以开始从那些提交并分支到另一个分支的分支。但是,我应该怎么做才能将2个提交合并在一起,以便大文件不会显示在历史记录中,并且在垃圾收集过程中被清除了?
使用 BFG Repo-Cleaner ,更简单,更快速的替代方案到 git-filter-branch
专门用于从Git历史记录中删除不需要的文件。 仔细地按照使用说明,核心部分就是这样:
$ java -jar bfg.jar --strip-blobs-greater-than 100M my-repo.git
超过100MB大小的任何文件(不在您的 latest> 提交中)将从您的Git存储库的历史记录中删除。然后你可以使用 git gc
清除死点数据:
$ git gc --prune = now --aggressive
BFG通常至少 10-50x 比运行 git-filter-branch更快,并且通常更易于使用。
完全披露:我是BFG Repo-Cleaner的作者。 >
Occasionally I dropped a DVD-rip into a website project, then carelessly git commit -a -m ...
, and, zap, the repo was bloated by 2.2 gigs. Next time I made some edits, deleted the video file, and committed everything, but the compressed file is still there in the repository, in history.
I know I can start branches from those commits and rebase one branch onto another. But what should I do to merge together the 2 commits so that the big file didn't show in the history and were cleaned in garbage collection procedure?
Use the BFG Repo-Cleaner, a simpler, faster alternative to git-filter-branch
specifically designed for removing unwanted files from Git history.
Carefully follow the usage instructions, the core part is just this:
$ java -jar bfg.jar --strip-blobs-bigger-than 100M my-repo.git
Any files over 100MB in size (that aren't in your latest commit) will be removed from your Git repository's history. You can then use git gc
to clean away the dead data:
$ git gc --prune=now --aggressive
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.
这篇关于如何从Git存储库中的提交历史中删除/删除大文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!