Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git blame --color-by-age set as default in git config

I would like to setup git blame --color-by-age as the default behavior whenever I invoke git blame. How would I configure my .gitconfig file to achieve this?

like image 789
Kevin Avatar asked Jul 29 '18 22:07

Kevin


People also ask

How do I blame in git?

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 git config command?

The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to . gitconfig text files. Executing git config will modify a configuration text file.

How do I change git settings?

The global git config is simply a text file, so it can be edited with whatever text editor you choose. Open, edit global git config, save and close, and the changes will take effect the next time you issue a git command. It's that easy.


1 Answers

git config --global blame.coloring highlightRecent

From git-config(1):

blame.coloring

This determines the coloring scheme to be applied to blame output. It can be repeatedLines, highlightRecent, or none which is the default.

and

color.blame.highlightRecent

This can be used to color the metadata of a blame line depending on age of the line.

This setting should be set to a comma-separated list of color and date settings, starting and ending with a color, the dates should be set from oldest to newest. The metadata will be colored given the colors if the the line was introduced before the given timestamp, overwriting older timestamped colors.

Instead of an absolute timestamp relative timestamps work as well, e.g. 2.weeks.ago is valid to address anything older than 2 weeks.

It defaults to blue,12 month ago,white,1 month ago,red, which colors everything older than one year blue, recent changes between one month and one year old are kept white, and lines introduced within the last month are colored red.

like image 66
Ry- Avatar answered Oct 02 '22 03:10

Ry-