V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
AndyAO
V2EX  ›  问与答

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

  •  1
     
  •   AndyAO · 2021-06-18 12:11:20 +08:00 · 578 次点击
    这是一个创建于 1014 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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才行。

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

    4 条回复    2021-06-18 12:36:28 +08:00
    AoEiuV020
        1
    AoEiuV020  
       2021-06-18 12:16:24 +08:00
    xuboying
        2
    xuboying  
       2021-06-18 12:16:42 +08:00
    git rm 的操作是针对 git 系统的也就是必须被 index 索引的东西。
    如果你不想修改 git index,或者这个东西和 git 无关,就要用普通的 rm
    noe132
        3
    noe132  
       2021-06-18 12:21:14 +08:00   ❤️ 1
    git rm:
    ✅ 从 index 删除
    ✅ 从 index 和 working tree 删除
    ❌ 从 working tree 删除
    AndyAO
        4
    AndyAO  
    OP
       2021-06-18 12:36:28 +08:00
    问题已解决,谢谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1711 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 16:40 · PVG 00:40 · LAX 09:40 · JFK 12:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.