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:
Error:error: pathspec 'app/src/main/java/blahblah/FooBar.java' did not match any file(s) known to git.
FOOBar.java
, re-creating FooBar.java
, adding/committing with Gitin the file system:
.gradle
folder in the project folder, then trying one of the above in Android Studio
from the Git command line:
git mv FOOBar.java FooBar.java --force
then git commit FooBar.java -m 'renamed from FOOBar.java to FooBar.java'
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'