git rm 的文档好像前后矛盾,是哪里理解错了吗?

2021-06-18 12:11:20 +08:00
 AndyAO

git-rm - Remove files from the working tree and from the index

Remove files matching pathspec from the index, or from the working tree and the index. git rm will not remove a file from just your working directory. (There is no option to remove a file only from the working tree and yet keep it in the index; use /bin/rm if you want to do that.)

这里摘录了 git rm 文档中的两段话。

第 1 段话说明 git rm 可以删除工作树中的文件,但第 2 段的意思好像是说,git rm不能从工作树中删除文件,如果需要的话必须使用/bin/rm才行。

感觉这两段话是前后矛盾的。

584 次点击
所在节点    问与答
4 条回复
AoEiuV020
2021-06-18 12:16:24 +08:00
xuboying
2021-06-18 12:16:42 +08:00
git rm 的操作是针对 git 系统的也就是必须被 index 索引的东西。
如果你不想修改 git index,或者这个东西和 git 无关,就要用普通的 rm
noe132
2021-06-18 12:21:14 +08:00
git rm:
✅ 从 index 删除
✅ 从 index 和 working tree 删除
❌ 从 working tree 删除
AndyAO
2021-06-18 12:36:28 +08:00
问题已解决,谢谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/784194

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX