为什么使用'git rm'来删除文件而不是'rm'?

编程入门 行业动态 更新时间:2024-10-27 22:33:51
本文介绍了为什么使用'git rm'来删除文件而不是'rm'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在SVN上,直接从文件系统中删除某些东西(而不是使用svn)会造成一些令人头疼的负担。到目前为止,使用git,我没有发现这是一个问题,但我注意到git有它自己的rm实现。

是否有区别?如果你只是使用 rm ,我是否做错了什么?

解决方案您需要使用 git add< fileRemoved> 进行跟踪。 git rm 可以一步完成此操作。

您也可以使用 git rm - 缓存这将从索引中删除文件(暂存它在下一次提交时删除),但保留在本地文件系统中。

On SVN, removing something from the filesystem directly (rather than using svn) created a load of headaches. So far, using git, I haven't found this to be an issue, but I notice that git has it's own rm implementation.

Is there a difference? Am I doing something wrong?

解决方案

If you just use rm, you will need to follow it up with git add <fileRemoved>. git rm does this in one step.

You can also use git rm --cached which will remove the file from the index (staging it for deletion on the next commit), but keep your copy in the local file system.

更多推荐

为什么使用'git rm'来删除文件而不是'rm'?

本文发布于:2023-10-24 05:59:55,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   文件   git   rm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!