无法使用特殊字符进行 git rm
我在 git 存储库中添加了现在想要删除的文件。我用 rm XXX
删除了它。 现在, git status
向我展示:
Changed but not updated:
deleted: "Sche\314\201ma application + interface.graffle"
无论我如何 git rm
它,我仍然有一个:
fatal: pathspec 'Schêma application + interface.graffle' did not match any files
我试图用 \
转义空格,以使用 \\
转义 \
,使用 \"
转义 "
。无论我尝试什么,都失败了。
你有提示吗?
I added files in my git repository that I want to remove now. I deleted it with rm XXX
.
Now, git status
shows me:
Changed but not updated:
deleted: "Sche\314\201ma application + interface.graffle"
No matter how I git rm
it, I still have a :
fatal: pathspec 'Schêma application + interface.graffle' did not match any files
I tried to escape whitespaces with \
, to escape \
with \\
, to escape "
with \"
. No matter what I tried, it failed.
Do you have hints?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这将检测删除:
This will detect the remove:
尝试 git gui。你也许可以正确地逃避它,但它可能会带来太多的麻烦,而不是值得的。它应该正确地逃脱这个。
如果您的问题是暂存删除,只需
git add -A
将所有更改添加到索引。try git gui. You could probably escape it properly but it might be too much trouble than it's worth. It should escape this properly.
If your issue is staging removals, just
git add -A
to add all changes to the index.将其用单引号括起来。
如果需要转义文件名中的单引号,请将其用双引号括起来。因此,如果由于某种原因您的文件名是 '" (即单引号、双引号),请使用
第一组双引号包裹单引号,最后一组单引号包裹双引号。
这是为了总的来说是 Bash,不仅仅是 git。更多关于疯狂引用的信息:如何转义单引号字符串中的单引号?
Wrap it in single quotes.
If you need to escape single quotes in a file name, wrap those in double quotes. So if for some reason your file name is '" (that's single quote, double quote), use
where the first set of double quotes is wrapping the single quote, and the end set of single quotes is wrapping the double quote.
This is for Bash in general, not just git. More on quote insanity here: How to escape single-quotes within single-quoted strings?