Git:手动重命名文件,Git 困惑 [英] Git: renamed file manually, Git confused
问题描述
我正在使用 Git 并手动重命名我添加到存储库中的文件.现在,我添加了我重命名到存储库的新"文件,但 Git 抱怨旧"文件已被删除.那么如何让 Git 忘记旧文件呢?更好的是,我如何告诉 Git 新"文件确实是新"文件,以便我可以保持更改历史完整?
I am using Git and manually renamed a file that I had added to the repository. Now, I have added the "new" file which I renamed to the repository but Git complains that the "old" file has been deleted. So how can I make Git forget about the old file? Better yet, how do I tell Git that the "new" file really is the "new" file so that I can keep the change history intact?
推荐答案
没有问题.只需 git rm old
甚至 git add -A
,它就会意识到这是一个重命名.Git 将看到删除和添加与重命名相同的内容.
There is no problem. Simply git rm old
or even git add -A
and it will realize that it is a rename. Git will see the delete plus the add with same content as a rename.
您不需要撤消、取消暂存、使用git mv
等.git mv old new
只是mv old new 的简写;git rm 旧;git add new
.
You don't need to undo, unstage, use git mv
etc. git mv old new
is only a short hand for mv old new; git rm old; git add new
.
这篇关于Git:手动重命名文件,Git 困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!