Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to customize the output of git blame?

Tags:

git

blame

git log has a nice --format option to specify how the output should be formatted.

But git blame doesn't seem to have an equivalent, although default output of blame is not quite human-friendly. I would like to see much less.

For example, instead of:

5600cab7 js/sidebar/VehicleGrid.js        (Rene Saarsoo    2009-10-08 18:55:24 +0000 127)    if (x > y) { b5f1040c js/map/monitoring/VehicleGrid.js (Mihkel Muhkel   2010-05-31 07:20:13 +0000 128)        return x; 

I would like to have:

5600cab7 Rene Saarsoo (1 year ago)     127:    if (x > y) { b5f1040c Mihkel Muhkel (5 months ago)  128:        return x; 

I figure that I could write a script to parse the output of git blame --porcelain but given the horrendous default output of blame I feel that somebody out there must have already done something about it.

Any ideas? Or any tips for implementing such a script?

like image 290
Rene Saarsoo Avatar asked Oct 18 '10 12:10

Rene Saarsoo


People also ask

Is git blame useful?

Despite its negative-sounding name, git blame is actually pretty innocuous; its primary function is to point out who changed which lines in a file, and why. It can be a useful tool to identify changes in your code. Basically, git-blame is used to show what revision and author last modified each line of a file.

How does blame work in git?

Summary. The git blame command is used to examine the contents of a file line by line and see when each line was last modified and who the author of the modifications was. The output format of git blame can be altered with various command line options.

What is star in git blame?

Annotations for lines modified in the current revision, are marked with bold type and an asterisk. But I think it is important to clarify that this refers to lines modified in the current revision of the file, not the current revision of the repository.

How do I use git blame ignore revs?

In your repository, create a file to hold commit hashes of commits to be ignored by git blame . Naming this file . git-blame-ignore-revs seems to be a common convention. This causes git to automatically ignore the commits specified in that file for every call to git blame .


1 Answers

You can use alternate output format: git annotate or git blame -c.

You can change formatting of dates with --date=<format> option (or blame.date config variable), where <format> is one of relative, local, default, iso, rfc, short. See git-blame and git-log manpages for details.

like image 184
Jakub Narębski Avatar answered Oct 22 '22 02:10

Jakub Narębski