2

当我尝试使用命令精简我的仓库时:

git filter-branch --force --tree-filter 'rm -rf `/Volumes/RamDisk/FF/large_files.txt | cut -d " " -f 2` ' --prune-empty master

我在控制台中得到输出:

Rewrite 072caf825338a50130903528862caa12cebd1c87 (1/3214)/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-filter-branch: line 318: /Volumes/RamDisk/FF/large_files.txt: Permission denied
Rewrite 2e7c35b1dd73b2b2ceb010a3cd98ad6906b0716e (2/3214)/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-filter-branch: line 318: /Volumes/RamDisk/FF/large_files.txt: Permission denied...

large_files.txt 只是包含要删除的文件列表的文本文件,我拥有它并拥有所有权限:

-rwxrwxrwx   1 luka  staff   6983  3 Oct 23:00 large_files.txt

我确保 .git-rewrite 不在仓库中(已删除)并且强制标志没有帮助?

这到底是什么权限?文件系统权限、Git 远程权限还是其他?这是我的仓库,我可以完全访问它,用 sudo 尝试过,但没有任何帮助。顺便说一句: large_files.txt 只是带有要删除的文件列表的文本文件,

你能帮我理解我在这里想念什么吗?

4

1 回答 1

2

You're trying to execute large_files.txt (notice what's inside the ` characters in your argument to --tree-filter). The shell, perhaps confusingly, says "Permission denied" when you try to execute a file that is not executable (even if you optimistically set its permissions to a+x). You probably meant to have a cat in there somewhere, no?

By the way, it's probably safer to use xargs than to just expand that in the arguments to rm. For example:

cut -d " " -f 2 /Volumes/RamDisk/FF/large_files.txt | xargs rm -rf
于 2014-10-05T07:33:17.673 回答