NetBeans Tip - Git Blame Within NetBeans

Login | Register

NetBeans Tip - Git Blame Within NetBeans

NetBeans git

From the command line, if you need to know who changed a line of code within a git repository, you can execute the git blame command.

$git blame pom.xml
...
7ab5e99fd34 v3/extras/pom.xml             (Jerome Dochez            2008-02-01 04:39:37 +0000 45)     <modelVersion>4.0.0</modelVersion>
...

The same action can be performed directly from within NetBeans against the currently open file by selecting the Team | Show Annotations menu option. Selecting this, causes the left hand size of the selected code window to display the git hash and the user that last edited each line within the file, as shown in the code fragment from the GlassFish source code below.

You can disable viewing these annotations by selecting the Team | Hide Annotations menu option.

The annotations that are displayed for each line can be customised (for example, you may not wish to see the git hash). Right clicking on the annotations within the source code window displays a pop-up menu with the option to show:

  • revision
  • date
  • author

Selecting / unselecting these options changes the display accordingly.

About

At Develop In Java, we've been a part of the Java community for over 10 years. If there's anything you'd like us to cover, just ask !

Current versions

  • Java - 1.8
  • Java EE - 7
  • Spring - 4.x