为什么使用'git rm'来删除文件而不是'rm'? [英] Why use 'git rm' to remove a file instead of 'rm'?

查看:208
本文介绍了为什么使用'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'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆