使用git的'git rm'和'git mv'的实际用例? [英] Practical use case of 'git rm' and 'git mv' with git?

查看:185
本文介绍了使用git的'git rm'和'git mv'的实际用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道git提供'git rm'和'git mv'来移除/移动文件或目录。但是,我看不到这个实际的用例。

通常,我只是mv或rm文件或命令行中的任何内容,在完成所有必要的操作后,我可以运行'git add -u'和'git add。',正如我所问,并在 here



我错过了什么吗?是否有任何情况下只有'git rm'和'git mv'才有能力? 解决方案

git mv git rm 关于直接更新索引。直接移动或删除工作树中的文件不会立即影响索引。



GitFaq 的确存在 git mv


只是一种方便。效果与删除文件和添加具有不同名称和相同内容的文件无法区分。



I know that git provides the 'git rm' and 'git mv' to remove/move files or directories. But, I can't see the practical use case for this.

Normally, I just mv or rm the files or whatever in the command line, and after I'm done with all the necessary actions, I can just run 'git add -u' and 'git add .', as I asked and got answers in here.

Am I missing something? Are there any cases that only 'git rm' and 'git mv' capable of?

解决方案

git mv and git rm are about updating the index directly. While directly moving or deleting files in the working tree won't immediately affect the index.

The GitFaq does present git mv as:

just a convenience. The effect is indistinguishable from removing the file and adding another with different name and the same content.

这篇关于使用git的'git rm'和'git mv'的实际用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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