问题描述
我很好奇线条颜色在 git log --graph
中的含义是什么?
是的,我在询问 |
/
\
,它在控制台输出的左边连接提交 *
。
问题# 1
这些颜色是否有一些隐藏的含义?
或者它们是伪随机选择的?
问题#2
有时重叠(但不连通)的行具有相同的颜色。
例如,请看上面屏幕截图上的紫色线:
a55
到 e1c
3c1
到 043
是否有可能要求git明智地选择颜色以避免孤立常见提交)相同的颜色线重叠?
我希望图可以更容易阅读。
颜色只是为了帮助您查看与其他线条截然不同的线条。要回答问题1,每次 git log --graph
选择一个新的列时,它们不是伪随机分配的,而是按顺序分配的数。不幸的是,我知道有两个问题。两者都与您的问题#2相关。
:
GIT_COLOR_RED,
GIT_COLOR_GREEN,
GIT_COLOR_YELLOW,
GIT_COLOR_BLUE,
GIT_COLOR_MAGENTA,
GIT_COLOR_CYAN,
GIT_COLOR_BOLD_RED,
GIT_COLOR_BOLD_GREEN,
GIT_COLOR_BOLD_YELLOW,
GIT_COLOR_BOLD_BLUE,
GIT_COLOR_BOLD_MAGENTA,
GIT_COLOR_BOLD_CYAN,
在视觉上,许多颜色看起来相同(或者相似程度足以容易区分)。特别是,我发现大胆的字体看起来太像常规字体,除非有相当多的字母以粗体打印,即我的Mac Terminal字体的大胆字体不会那么大胆 - 呃比它的标准重量。例如,在Git仓库中为Git运行 git log --graph --decorate --oneline --all
时,这会使许多行在视觉上过于类似。
编辑:现在可以使用新的来修复(或变通) log.graphColors
配置条目。这是逗号分隔的颜色名称或颜色编号列表(请参阅并编写新代码。我会注意到现有的接近1400行,尽管如此。
I'm curious what do line colors mean in git log --graph
?
Yes, I'm asking about lines |
/
\
which connect commits *
at the left edge of console output.
Question #1
Do these colors have some hidden meaning?
Or do they are pseudo-randomly chosen?
Question #2
Sometimes overlapped (but disconnected) lines have the same color.
For example, see at the purple lines on the screenshot above:
- first line from
a55
toe1c
- second line from
3c1
to043
Is it possible to ask git to choose colors wisely to avoid isolated (not having common commit) same color lines to overlap?
I want the graph to be more easily readable.
The colors are merely meant to help you view the lines as distinct from other lines. To answer question #1, they are assigned not pseudo-randomly, but rather sequentially, each time git log --graph
picks a new "column number". Unfortunately there are two issues I know of. Both tie into your question #2.
Here is the full list of colors by name:
GIT_COLOR_RED,
GIT_COLOR_GREEN,
GIT_COLOR_YELLOW,
GIT_COLOR_BLUE,
GIT_COLOR_MAGENTA,
GIT_COLOR_CYAN,
GIT_COLOR_BOLD_RED,
GIT_COLOR_BOLD_GREEN,
GIT_COLOR_BOLD_YELLOW,
GIT_COLOR_BOLD_BLUE,
GIT_COLOR_BOLD_MAGENTA,
GIT_COLOR_BOLD_CYAN,
Visually, many of these colors "look the same" (or similar enough to be kind of indistinguishable). In particular, I find that the "bold" ones look too much like the "regular" ones unless there are quite a few letters printed in "bold", i.e., my Mac Terminal font's "bold" is just not that much bold-er than its standard-weight. This makes many lines overly visually similar in the graph for git log --graph --decorate --oneline --all
run on the Git repository for Git, for instance.
Edit: this is now fixable (or work-around-able), as of Git 2.12, using the new log.graphColors
configuration entry. This is a comma separated list of color names or color numbers (see the git config
documentation entry for "color" in the Values section).
Second, the "column number" is, currently, not actually the column number of the line. Instead, it's the column number of the commit. The line color goes up from that commit, to the commit above it. All the magenta lines in your image snapshot go to commits printed in column #0: both a55fd8d
and 3c1494a
are in "column 0". (They are both merge commits so they consolidate incoming lines.)
You can always clone the Git repository for Git and write new code. I will note that the existing graph.c is nearly 1400 lines long, though.
这篇关于git log --graph中的线条颜色是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!