我想使用filter-branch将所有文件设置为不可执行文件,因为大多数用户使用Windows。我在Git Bash中运行了以下命令:
git filter-branch --index-filter 'for file in $(git ls-files)
do
git update-index --chmod=-x -- $file
done' -- HEAD~1..HEAD
但是,我收到一条错误消息:
Rewrite bc4368aec16cce1c1faa7363dde9ac74ac28da6a (1/1)
error: .gitignore: does not exist and --remove not passed
fatal: Unable to process path .gitignore
error: LICENSE.md: does not exist and --remove not passed
fatal: Unable to process path LICENSE.md
error: README.md: does not exist and --remove not passed
fatal: Unable to process path README.md
由于我在Windows上,我甚至无法使用-tree-filter和chmod(至少这对我没用)。当我使用--filter-tree而不是--filter-index时,它可以工作,但我试图使用--filter-index,因为它应该更快。
答案 0 :(得分:1)
虽然你的问题主要集中在git filter-branch
进行重写,但是值得考虑使用BFG - 尽管它没有开箱即用,但它相当小调整以添加TreeBlobs
清除程序,将所有文件设置为不可执行文件:
https://github.com/rtyley/bfg-repo-cleaner/compare/non-executable
您可以非常轻松地构建自定义版本的BFG:
https://github.com/rtyley/bfg-repo-cleaner/blob/master/BUILD.md
使用上面的non-executable
分支,您可以在没有任何额外命令行开关的情况下运行BFG,因为清理器是硬连线的(跟随BFG的所有usage instructions,这只是核心位):
$ java -jar bfg-custom.jar my-repo.git
这将比任何大型存储库上的git filter-branch
(有或没有--filter-index
)执行快几百倍 - 例如,我在linux-kernel项目上对此自定义清理程序进行了测试运行( 〜500k提交),在5分钟内完成。
完全披露:我是BFG Repo-Cleaner的作者。