git log --graph 中的线条颜色是什么意思? [英] What do line colors in git log --graph mean?

查看:28
本文介绍了git log --graph 中的线条颜色是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇 git log --graph 中的线条颜色是什么意思?

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.

问题 #1
这些颜色有什么隐藏的含义吗?
或者它们是伪随机选择的?

Question #1
Do these colors have some hidden meaning?
Or do they are pseudo-randomly chosen?

问题 2
有时重叠(但不连续)的线具有相同的颜色.
例如,请参见上面屏幕截图中的紫色线条:

Question #2
Sometimes overlapped (but disconnected) lines have the same color.
For example, see at the purple lines on the screenshot above:

  • 第一行从 a55e1c
  • 3c1043的第二行
  • first line from a55 to e1c
  • second line from 3c1 to 043

是否可以要求 git 明智地选择颜色以避免孤立(没有共同提交)相同颜色的线条重叠?
我希望图表更易于阅读.

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.

推荐答案

颜色只是为了帮助您将线条与其他线条区别开来.为了回答问题#1,它们不是伪随机分配的,而是顺序分配的,每次 git log --graph 选择一个新的列号".不幸的是,我知道有两个问题.两者都与您的问题 #2 有关.

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.

以下是按名称列出的完整颜色列表:

    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 终端字体的粗体"并不是那么粗体比它的标准重量.例如,对于在 Git 的 Git 存储库上运行的 git log --graph --decorate --oneline --all,这使得许多行在视觉上过于相似.

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.

编辑:从 Git 2.12 开始,现在可以使用新的 log.graphColors 配置条目修复(或解决).这是一个逗号分隔的颜色名称或颜色编号列表(参见 值部分中颜色"的 git config 文档条目).

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).

其次,列号"目前实际上不是行的列号.相反,它是提交的列号.线条颜色从那个提交 up 到它上面的提交.图像快照中的所有洋红色行都转到第 0 列中打印的提交:a55fd8d3c1494a 都在第 0 列"中.(它们都是合并提交,因此它们合并传入的行.)

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.)

是否可以要求 git 明智地选择颜色以避免孤立(没有共同提交)相同颜色的线条重叠?

Is it possible to ask git to choose colors wisely to avoid isolated (not having common commit) same color lines to overlap?

您始终可以克隆 Git 的 Git 存储库 并编写新代码.我会注意到现有的 graph.c 将近 1400 行,不过.

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 中的线条颜色是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆