Reputation: 87
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
Upvotes: 4
Views: 1851
Reputation: 4311
(tested with Android Studio Jellyfish, Dec 2024)
In my case, it seems that for whatever reason (such as I was working on an old, slow Mac on MacOS Catalina), Android Studio did not find the git location upon starting up, then when I tried to do things like git blame
(to annotate with git), or show git log
from the Git menu, it failed. git blame
did nothing at all, and showed nothing. show git log
showed the empty UI where normally it would show the git log.
However, I went to Preferences -> Version Control -> Git and saw that Android Studio had in fact found the location of the git executable on this machine, as seen in this screenshot.
Anyway, I clicked "Test", and it changed to the following, actually finding the version of git (besides the path) and displaying it.
For whatever reason, that appeared to do the trick. I went away for some coffee, and when I came back, git was working fine, including git blame
, show git log
, and so on.
Upvotes: 0
Reputation: 5625
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:
Version Control
tabThat's it, fixed my annotate and git change highlighting issues.
Upvotes: 6
Reputation: 3547
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"
Upvotes: 2