从Git中删除敏感数据。 “致命的:模棱两可的论点'rm'” [英] Removing sensitive data from Git. "fatal: ambiguous argument 'rm'"
问题描述
git filter-branch --force --index-filter'git rm --cached --ignore-unmatch filename.js'--prune-empty --tag-name-filter cat - --all
但我一直得到这个错误:
致命:ambiguous argument'rm':unknown修订版或路径不在工作树中
。
使用' - '分隔修订版本的路径,如下所示:
'git< command> '< revision> ...] - [< file>]'
它取决于您正在使用的shell。
在Windows上,例如msysgit,请参阅 issue 477 :
$ b
单引号与CMD没有特殊的含义。不要指望它们和POSIX shell一样工作
。调用filter-branch像这样:
git filter-branch --commit-filterGIT_COMMITTER_NAME = void GIT_AUTHOR_NAME = void GIT_COMMITTER_EMAIL=just.a.test@kernel.org GIT_AUTHOR_EMAIL=just.a.test@kernel.org; git commit-tree \$ @ \HEAD
$ c
$ b 多行:
git filter -branch --commit-filterGIT_COMMITTER_NAME = void \
GIT_AUTHOR_NAME = void \
GIT_COMMITTER_EMAIL=just.a.test@kernel.org \
GIT_AUTHOR_EMAIL = just.a.test @ kernel.org; \
git commit-tree \$ @ \HEAD
正如在如何将一个编程生成的文件列表传递给 git filter-branch code>?
每个参数各种 ...- filters
需要是单个字符串。这个字符串保存为一个shell变量。
所以确保'git rm --cached --ignore -unmatch filename.js'
被认为是你所在shell中的一个字符串。
I'm trying to run this command:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch filename.js' --prune-empty --tag-name-filter cat -- --all
but I keep getting this error:
fatal: ambiguous argument 'rm': unknown revision or path not in the working tree
.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
解决方案 It depends on the shell you are using.
On Windows, with msysgit for instance, see issue 477:
Single quotes do not have a special meaning with CMD. Do not expect that they work
the same as with a POSIX shell. Call filter-branch like this:
git filter-branch --commit-filter "GIT_COMMITTER_NAME=void GIT_AUTHOR_NAME=void GIT_COMMITTER_EMAIL=just.a.test@kernel.org GIT_AUTHOR_EMAIL=just.a.test@kernel.org; git commit-tree \"$@\"" HEAD
Multiple lines:
git filter-branch --commit-filter "GIT_COMMITTER_NAME=void \
GIT_AUTHOR_NAME=void \
GIT_COMMITTER_EMAIL=just.a.test@kernel.org \
GIT_AUTHOR_EMAIL=just.a.test@kernel.org; \
git commit-tree \"$@\"" HEAD
As mentioned in "How to pass a programmatically generated list of files to git filter-branch
?"
Each argument to the various ...-filters
needs to be a single string. That string is saved as a shell variable.
So make sure 'git rm --cached --ignore-unmatch filename.js'
is considered a string in the shell you are in.
这篇关于从Git中删除敏感数据。 “致命的:模棱两可的论点'rm'”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!