我在将一些文件添加到 .gitignore
后希望清理我的仓库,所以我运行了 git rm --cached *
命令,结果如下:fatal: pathspec '$Recycle.Bin' did not match any files
我猜测这是由于文件名中的 $
符号导致的,是否有一种解决方法?
我在将一些文件添加到 .gitignore
后希望清理我的仓库,所以我运行了 git rm --cached *
命令,结果如下:fatal: pathspec '$Recycle.Bin' did not match any files
我猜测这是由于文件名中的 $
符号导致的,是否有一种解决方法?
这只是*
的工作原理,与$
无关。
$ ls
$Recycle.Bin
a
b
git rm --cached *
,shell会将其转换为git rm --cached $Recycle.bin a b
,并将其传递给Git。$Recycle.Bin
不是你的仓库的一部分,所以Git无法删除它。这是一个错误。最简单的解决方法是不使用--ignore-unmatch
。$ git rm --cached --ignore-unmatch -- *
-r
谢谢! git rm --cached --ignore-unmatch -r -- *
- ehiller