A better way to “git blame” in Android Studio

If you use git in your software projects, you might be familiar with the git blame command. It does pretty much what it sounds like: it lets you blame each line in a file to whoever last made changes to that line. If you’re not familiar with git blame, go ahead and try it on the command line:

$ git blame -- path/to/my/source/file

You should see something this:

Output of git blame

You can see who last modified each line, when the change was made as well as the short hash of the relevant commit. In this example you only see my name because apparently I’m the only one who last modified each line of this file at the same time (which likely means that this was when the file was created and it has not been updated since), but depending on the situation it could mention multiple authors, timestamps and short hashes.

This works great when you’re working from the command line, but it seems a bit too primitive to use when you have the power of an IDE. Shouldn’t Android Studio provide some sort of functionality that works with this?

Introducing Annotate

That’s what they call it in Android Studio (and IntelliJ and possibly other JetBrains IDEs). It does exactly what git blame does – but in a nicer, IDE-friendly way.

Where to find Annotate

If you want to see more information than just the author name and the date modified, just right click on the annotated area, go into View then select what you want to see.

It’s pretty neat for when you want to find someone to blame. 😉

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.