无法提交一个文件,意外更名为mv [英] unable to commit a file, accidentally renamed with mv

查看:274
本文介绍了无法提交一个文件,意外更名为mv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不小心使用了mv来重命名git下的文件。我将
文件从小写更名为大写,保持名称相同。



mv abc.java ABC.java



之后我也做了更改并提交了文件。

现在我如何对这个文件进行实际的git重命名? Git bash似乎并不了解ABC.java和abc.java之间的区别。



我不确定master(其他人)发生了什么变化,但移动后到一个分支,我无法将更改提交到文件。它说旧的文件索引仍然存在。
$ b $ p $ git commit -m重命名为大写ABC.java
致命的:不会添加文件别名
'dir1 / ABC.java'('dir1 / abc.java'已存在于索引中)



当我执行git status时,它显示重命名的文件,但不让我提交重命名的文件。如果我尝试删除abc.java(实际上不存在,至少在本地),再次(我认为由于不区分大小写)git删除新的。



如果我克隆了一个新的repo,repo仍然会提取具有旧名称(abc.java)的文件,但是我的所有更改直到最近失败的文件存在于其中。

解决方案

一个简单的git commit -mmessage没有任何文件路径参数对我来说是诀窍。它更新了我认为或至少最终能够识别abc的索引,并将其更新为ABC ..谢谢大家。


I've accidentally used mv to rename a file which was under git. I renamed the file from lower case to uppercase keeping the name same.

mv abc.java ABC.java

I've also made changes and committed the file after that .

How do I now make an actual git rename of this file? Git bash doesn't seem to understand the difference between ABC.java and abc.java.

I'm not sure what changed on master(by others) but after moving to a branch, I'm no more able to commit my changes to the file. It says the old file index still exists.

$ git commit -m "renamed to uppercase" ABC.java fatal: Will not add file alias 'dir1/ABC.java' ('dir1/abc.java' already exists in index)

When I do git status, it shows the renamed files but doesn't let me commit the renamed files. If I try to do a delete abc.java(which is actually not present at least locally), again (I think because of case insensitivity) git deletes the new one.

If I clone a new repo out of this, the repo still pulls out the files with old name(abc.java) but all my changes until the recently failing ones are there in it.

解决方案

A simple git commit -m "message" without any file path parameter did the trick for me. It updated the index I think or atleast finally it was able to recognize abc is to be updated to ABC.. Thank you all..

这篇关于无法提交一个文件,意外更名为mv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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