Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio GIT error when trying to annotate

Tags:

git

android

When I right click on the side and click "Annotate" I get the following error

Error:Failed to annotate: com.intellij.openapi.vcs.VcsException: fatal: no such path app/src/main/java/.. ../MainActivity.java in HEAD during executing git -c core.quotepath=false blame --porcelain -l -t -w HEAD -- app/src/main/java/.. ../MainActivity.java

Google didnt help. I tried cloning the repo again but didnt work. I have no idea whats going on.

Also when I try to look at the history, the console says something like

fatal: no such path .../MainActivity.java in HEAD

like image 767
user1153395 Avatar asked Aug 30 '25 17:08

user1153395


2 Answers

I struggled for months with this happening but just for Git submodule code - and in my case the "Oh you renamed your folders" solutions didn't help me at all.

Finally this was the solution for my case:

  1. Go to Android Studio Preferences, Version Control tab
  2. Under the Directory list, add in all the submodule root folders (you may find they are already there but under an "Unregistered" header in the list - in that case you can simply select those and hit the + button, bottom left, to add them.)

That's it, fixed my annotate and git change highlighting issues.

like image 114
Mete Avatar answered Sep 02 '25 08:09

Mete


The OP got it resolved now, but I am answering this for who came across this problem like I just did.

The paths in git repo are case-sensitive. So try to rename your folder in git to match the checkout folder on your system, especially if you are on Mac/Linux. Try run annotate again should work now.

git mv FOO foo2
git mv foo2 foo
git commit -m "Fix case sensitivity"
like image 43
Ken Ratanachai S. Avatar answered Sep 02 '25 08:09

Ken Ratanachai S.