git,在所有分支上过滤分支

标签 git git-filter-branch git-rewrite-history

我正在使用以下来源从我的存储库中删除一些大文件和目录:

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>…]

继续阅读,文档的开头说:“让您通过重写 中提到的分支来重写 git 修订历史,在每个修订上应用自定义过滤器。”

因此检查文档中的 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/

相关文章:

Github Fork 和 Pull : My PR was accepted, 如何继续在我的 fork 上工作?

git - 使用 --amend 重写提交后 CodeCommit 失败

git - 如何通过文件哈希从 git 存储库中查找文件修订或提交?

git - merge 后压缩 Git 提交

git - 在 Git 中编辑根提交?

Git 子模块与依赖管理?

git - 为什么 no-op filter-branch 会产生分歧,我该如何解决?

git 按子文件夹拆分存储库并保留所有旧分支

git log --all 在过滤器分支内不起作用

Git:从历史记录中删除文件夹,除了一位作者