43

I am trying to look at who changed a line in Intellij 15. I know I can use git blame but I want to learn how to do it correctly in intellij. I am right clicking on the line numbers on the file but when I get the context menu the annotate option is grayed out. What setting am I missing?

I looked at this page and couldn't find an answer. What am I missing?

ford prefect
  • 6,008
  • 10
  • 51
  • 78

12 Answers12

37

If you check File > Settings > Version Control and see that your current project is listed under "Unregistered Roots", go to (on the menubar) VCS > Enable Version Control Integration. It will ask you to select the VCS tool you use, then click ok and you'll have all the integrations working (including the annotate feature which uses git blame).

Amndeep7
  • 1,764
  • 4
  • 15
  • 23
Jason Howell
  • 386
  • 1
  • 3
  • 3
  • 1
    Checking ```File > Settings > Version Control``` was useful for me even after I had enabled integration, as the resolution of the root path involved a symlink. After adding the non symlinked path, it works as expected. – snapfractalpop Jan 30 '19 at 03:48
  • there is no "Enable Version Control Integration" in current version of IntelliJ. How to do it in current version? – eis Apr 08 '20 at 10:27
  • 3
    ah, found it! I had to go to "File > Settings > Version Control", find the project with unregistered root and press a plus sign ("+"). After that, everything works. – eis Apr 08 '20 at 10:32
32

The answer by @activedecay let me in the right direction. In my case, I have a multi-module project - each has a separate git repo - but we're all in the same workspace.

In my case, Intellij IDEA 2017.2, the Preferences -> Version Control panel shows a listing of all the project roots. The module with the disabled "Annotate" option was in the "Unregistered Roots" section.

To fix the problem, I selected the module and pressed the "+" icon in the lower toolbar to register the module root with Intellij VCS. The change is immediate and the "Annotate" options becomes available.

Mark D
  • 479
  • 4
  • 5
16

Looks like its a fresh project. First configure the Version Control like Git and than commit at least once. After first commit Annotate option will not be grayed out.

Also update git for any new version.

abcdef123
  • 204
  • 2
  • 5
  • It didn't help for me anyway :( I have idea 2018.2 and git 2.19.0 and mac os 10.13 Git was downloaded with homebrew – Valerii Oct 02 '18 at 13:30
13

Your VCS is not enabled, hence the issue. Below is the solution for that:

  1. Click on the VCS option in the menu bar
  2. Enable VCS
  3. Select your version control
  4. Done, you should be able to use the annotate option.
Apurv Nerlekar
  • 2,261
  • 1
  • 19
  • 29
12
  1. Make sure the file is tracked by version control
  2. Add the project to "Version Control" settings version control settings
activedecay
  • 8,238
  • 3
  • 40
  • 54
4

I had the same issue with the Annotate being greyed out however VCS was already set up. Editing the current VCS Directory Mapping fixed the issue for me.

Go to

  • Settings -> Version Control
  • Click on the current entry for your your application listed under projects.
  • Click the pen icon to edit it
  • Hit Ok, then ok to close the main dialog
Burf2000
  • 4,438
  • 11
  • 47
  • 100
  • For me, it was the git executable. it was not in the given path. had to change the path and then it worked. – ssi-anik Nov 02 '20 at 02:09
1

I the following two screen short will solve your problem: 1. enter image description here

  1. enter image description here

I hope after those steps you will be able to see who changed a line.

Salahin Rocky
  • 365
  • 7
  • 16
1

Here are the steps i followed : Go to VCS -> Checkout from Version Control -> Git -> give the URL for your repository.

The annotate option will be enabled now.

DISHA
  • 141
  • 1
  • 3
0

I had exactly the same issue and managed to solve it by updating git. The reason for that is that I have recent InteliJ Idea and an old 2.1.x git installed.

For Mac:

brew upgrade git
brew link git

followed by IDE restart.

ssh_imov
  • 1
  • 1
  • 2
0

Perhaps you did not check Git Integration while setting up a fresh installation of IntelliJ. It happened to me when I updated to a major release. When I was setting up the new program, I might have unchecked the Git Integration on the wizard installation.

In order to solve this for IntelliJ Community 2019.1, access File > Settings > Plugins, go to the tab Installed and make sure the plugin Git Integration is checked. You should restart the IDE in order to make the Annotate action work.

jotaEsse
  • 261
  • 2
  • 18
0

I had the same issue, but my VCS settings were all configured properly. It turns out that git itself was considering the file as a brand new file and therefore didn't have any history for it. The file was actually not new, but simply renamed. While my rename changes were unstaged, git understood it as two separate files: a deletion of the old file and creation of a new file. However, once I git added the "deleted" file and the "new" file, git understood that it was actually a rename and IntelliJ was able to annotate on the file as expected.

I'm not sure why git didn't understand the rename when it was unstaged, but hopefully this helps someone!

Logan
  • 1,128
  • 12
  • 21
0

Under the version control setting, make sure to remove any unregistered roots, I had a similar issue where there was a Unregistered roots entry was found, after removing this unwanted entry, I was able to annotate on file.

unregistered roots

Rakesh
  • 607
  • 2
  • 10
  • 29