Search code examples
gitgithubgit-branchgit-resetgit-mv

unable to commit a file, accidentally renamed with mv


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.


Solution

  • 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..