For example, I have a file named FOOBar.java
that I want to rename to FooBar.java
. After trying lots of stuff, I get the error:
I also faced the almost same situation, in my case I have created a file and added to git (using git add ), after adding to git I have renamed the file. While committing I got the same type error. I solved with the following step
use git status to see the staged files you can see your old file in the list
-
-
app/src/main/java/blahblah/FOOBar.java
-
-
use git reset to remove file from staging
git reset app/src/main/java/blahblah/FOOBar.java
After removing from staging you can add your new file
git add app/src/main/java/blahblah/FooBar.java
after this you can commit
http://binaryjeremys.blogspot.com/2015/03/android-studio-doesnt-like-it-when-you.html
To fix this issue, I had to reset to head with the steps below:
Backup the files first: Right-click one of the files and chose "Show in Explorer". Make copies of any files that have changed or the entire project to be safe. In Android Studio Delete all conflicting/erroring objects. VCS -> Git -> Reset Head WARNING: This will reset everything to the last time you did a commit to head. Once this is complete, just to be sure: Close the project, close Android studio, then reopened both. Create new classes to replace the deleted conflicting objects with the correct name. Replace the contents of these files, or copy/paste the backup files into the folder. Commit and push your changes now, and it should work.
Follow the link for main problem cause.
I had a similar problem and i fixed it changing git config:
git config core.ignorecase false
Windows’ file system is mostly case-insensitive, so you cannot rename a file by just changing its capitalization. Instead, you will have to use a temporary name in between.
Try the following from the command line:
git mv FOOBar.java FooBar.java.new
git mv FooBar.java.new FooBar.java
git commit -m 'Rename file'
A really simple fix I found was to do this command in terminal
git reset
I found out a very simple solution to this. Say you need to rename a java package "Activities" to "activities". This package contains several files and sub-packages
Follow the sequence of steps
Thats All Folks !