【发布时间】:2012-02-15 03:16:29
【问题描述】:
我正在研究通过删除二进制文件来减少 repo 大小的方法。我正在编写基于http://help.github.com/remove-sensitive-data/ 的脚本
似乎我有解决方案,但不知何故我无法将参数传递给嵌套的 git 命令。 带有硬编码文件的脚本有效:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch /*selenium-server-standalone-2.16.0.jar' --prune-empty -- --all
git push origin master --force
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
git status
git pull
这给了我输出
Rewrite f9a33e41dd6da4630773272ec18d194d14935a83 (10/10)rm 'bin/selenium-server-standalone-2.16.0.jar'
rm 'selenium-server-standalone-2.16.0.jar'
Ref 'refs/heads/master' was rewritten
Ref 'refs/remotes/origin/master' was rewritten
WARNING: Ref 'refs/remotes/origin/master' is unchanged
但是当我尝试对其进行参数化时,如下所示,整个过程不起作用
fileOLD=selenium-server-standalone-2.16.0.jar
git filter-branch --index-filter 'git rm --cached --ignore-unmatch /*${fileOLD}' --prune-empty -- --all
git push origin master --force
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
git status
git pull
输出
Rewrite 0491bf3461726c2ebd595ebc480010b5bf722302 (1/10)fatal: '/About Administration Tools.app' is outside repository
index filter failed: git rm --cached --ignore-unmatch /*${fileOLD}
它不会删除文件。
问题是如何在将变量传递到嵌套的 git 命令时正确传递/转义变量? (MAC OS x 10.7.2)
【问题讨论】: