Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the colors for tag/branch names in git log?

Tags:

git

When I run the command git log --graph --oneline --all --decorate I see branch and tag names in color (I think since I set color.ui to auto). I like this, however a couple of the colors are very hard to read, especially yellow, since I have a white background.

I would like to change this, and I found (in the Git book under color.* here: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration) that you can change settings under color.* to further customize Git's colors. However, none of the 4 subsettings (branch, diff, interactive, and status) seem to affect the colors used by git log for branch and tag names. Is it possible to change these colors, and if so how?

like image 860
Stephen Avatar asked Feb 08 '18 21:02

Stephen


2 Answers

In my config I have color.diff.commit set to yellow. I just tested command

git -c color.diff.commit=green log

and the color of commit is surely changed to green. See my .gitconfig and (separately included) colors (also in a personal git repo).

Upd. For branch and tags colors you need to set color.decorate.branch and color.decorate.tag. Example (from my "light_bg" file):

[color "decorate"]
    HEAD = cyan
    branch = green
    tag = blue bold
like image 176
phd Avatar answered Oct 09 '22 21:10

phd


The git log --graph column colors are configurable through:

log.graphColors

as documented (not very well) in the git config manual.

The default set is red, green, yellow, blue, magenta, cyan, bold red, bold green, bold yellow, bold blue, bold magenta, bold cyan.

The decoration names (tag: tagname, HEAD, branch names, and so on) are colored according to color.decorate.slot, where slot is one of branch, remoteBranch, tag, stash, or HEAD. (This control setting was new in Git 1.7.2, so if you have Git 1.7.1 or older you don't have it.)

There are many more control knobs: search the git config documentation for the word color.

like image 27
torek Avatar answered Oct 09 '22 21:10

torek