Git - rm: 无法识别的选项 `--cached'

Git - rm: unrecognized option `--cached'

我将 dist 添加到我的 .gitignore,但它是以其他方式添加到树中的。
我正在尝试删除它并使用以下方法清理树:

rm dist --cached

但是出现错误:

rm: unrecognized option `--cached'

感谢任何帮助!

运行 rm dist --cached 将不起作用,因为 rm 命令没有 --cached 选项。

rm documentation: https://www.computerhope.com/unix/urm.htm

The rm command is one of the basic Unix commands.


--cached标志是git rm命令的选项之一。因此,您可以 运行: git rm -r --cached dist 取消暂存并从索引中删除 dist 文件夹。

git rm documentation: https://git-scm.com/docs/git-rm

--cached Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.

-r Allow recursive removal when a leading directory name is given.

以下线程也可能为您提供更多信息: