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?
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.
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.
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.
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
, ornone
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With