1

I am using Android Studio.

I can't commit my class after having changed its name.

I have a file home.java, I want to rename it into Home.java

I right click on the file name and Refractor>Rename

Then I try to commit this file by doing a right click > Git > Add

And finally right click > Git > commit file

But I have an error :

Error:error: pathspec 'app/src/main/java/com/myschool/myname/appname/Home.java' did not match any file(s) known to git.
 during executing git commit --only -F /private/var/folders/7n/9f1v9ctx4jz9yd6m55jvgj_80000gn/T/git-commit-msg-2479641134196922895.txt --author=myname -- app/src/main/java/com/myschool/myname/appname/Home.java
SMR
  • 6,628
  • 2
  • 35
  • 56
ZeenaZeek
  • 271
  • 3
  • 5
  • 16

2 Answers2

1

This is an often reoccuring problem:

git checkout branch_name
error: pathspec 'mybranch_name' did not match any file(s) known to git.

One of the possible reasons that this occurs is because there's either no matching branch_name in your locally fetched repos, OR there's multiple clones of the branch, so git doesn't know which you're trying to checkout on the initial branch creation..

In general one has to use the following command:

git checkout -t -b branch_name origin/branch_name

or

git checkout -t -b branch_name another_repo/branch_name

How to switch android version in local repo? might come in handy, which has a lot of extra information regarding your problem.

Community
  • 1
  • 1
Joey Dorrani
  • 247
  • 1
  • 1
  • That is not the point. I only have the branch master. It's all about the name of my file. Commit works perfectly with other files in the same branch. – ZeenaZeek Feb 20 '15 at 10:15
1

Try syncronizing the file. (Right mouse button over the file in "Project tab" and click on Syncronize;))