3

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

user1153395
  • 77
  • 1
  • 8
  • What does happen if you run the same `git` command in a terminal? – Lyubomyr Shaydariv Sep 11 '16 at 05:15
  • not sure how to do that in command line – user1153395 Sep 11 '16 at 05:17
  • Try to run `git -c core.quotepath=false blame --porcelain -l -t -w HEAD -- app/src/main/java/.. ../MainActivity.java ` in your working copy directory in your terminal. Maybe it will reveal something. – Lyubomyr Shaydariv Sep 11 '16 at 05:19
  • wow fuck. i got it. it was because i renamed my package by just changing the case and git didnt recognize it. so it thinks those files dont exist. I changed it back and it works now – user1153395 Sep 11 '16 at 05:31
  • It would work if you'd rename it with `git mv` or AS since I think you have configured AS/Git integration well. Just curious: which way exactly have you renamed the file so AS didn't execute `git mv` itself? – Lyubomyr Shaydariv Sep 11 '16 at 05:43

2 Answers2

6

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.

Mete
  • 5,495
  • 4
  • 32
  • 40
  • Perfect, thank you! It was under "Directory mappings", and the submodule path was there but as an "Unregistered root". When I selected it and added it with a +, the issue was fixed. – Sharp Jan 14 '23 at 15:47
2

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"
Ken Ratanachai S.
  • 3,307
  • 34
  • 43