Git:手动重命名文件,Git困惑 [英] Git: renamed file manually, Git confused

查看:146
本文介绍了Git:手动重命名文件,Git困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Git并手动重命名了我已添加到存储库的文件。现在,我添加了新文件,我将其重命名为存储库,但Git抱怨旧文件已被删除。那么我怎么让Git忘掉旧文件?更好的是,我该如何告诉Git新文件真的是新文件,以便我可以保持更改历史记录? 解决方案

没有问题。简单地 git rm old 甚至 git add -A ,它会意识到它是重命名的。



您不需要撤消,取消,使用 git mv 等等。 git mv old new 只是 mv old new的简写。 git rm old; 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?

解决方案

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.

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屋!

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