我正在使用以下来源从我的存储库中删除一些大文件和目录:
http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
Why is my git repository so big?
git filter-branch
似乎只适用于当前分支 - 有没有办法同时将其应用于所有分支?
最佳答案
解决方法很简单:
git filter-branch [选项] -- --all
请注意 -- --all
中的四个破折号(两组双破折号之间有一个空格)。
如果您查看 git-filter-branch
的文档,它是这样说的:
git filter-branch [--env-filter <command>] [--tree-filter <command>]
[--index-filter <command>] [--parent-filter <command>]
[--msg-filter <command>] [--commit-filter <command>]
[--tag-name-filter <command>] [--subdirectory-filter <directory>]
[--prune-empty]
[--original <namespace>] [-d <directory>] [-f | --force]
[--] [<rev-list options>…]
继续阅读,文档的开头说:“让您通过重写
因此检查文档中的 rev-list
给出:
< rev-list options >… Arguments for git rev-list. All positive refs included by these options are rewritten. You may also specify options such as --all, but you must use -- to separate them from the git filter-branch options.
git-rev-list
的文档说:
--all
Pretend as if all the refs in refs/ are listed on the command line as <commit>.
关于git,在所有分支上过滤分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7430717/