为什么使用'git rm'来删除文件而不是'rm'? [英] Why use 'git rm' to remove a file instead of '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'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!