如何在git diff中自定义diff标头的颜色? [英] How do you customize the color of the diff header in git diff?

查看:161
本文介绍了如何在git diff中自定义diff标头的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行git diff时,每个差异的标题部分都显示为白色文本.由于我使用的是浅色背景,因此很难阅读,因此我想对其进行更改.

When I run git diff, the header part of each diff comes out in white text. Since I'm using a light background it is hard to read, so I want to change it.

我发现我可以像这样(在.gitconfig中)更改diff输出中的其他颜色:

I have found that I can change other colors in the diff output like this (in .gitconfig):

[color "diff"]
    old = green
    new = red

但是我无法弄清楚标题颜色该放在哪里.更好的是,是否有记录所有默认git config设置的地方?

But I can't figure out what to put there for the header color. Even better, is there someplace where all of the default git config settings are documented?

差异标头"是指这样的行:

By 'diff header' I mean lines like this:

diff --git a/README.md b/README.md
index f102026..c5e3428 100644
--- a/README.md
+++ b/README.md

推荐答案

尝试设置color.diff.meta,例如

git config --global color.diff.meta blue

或通过手动编辑配置文件

or by manually editing the configuration file

[color "diff"]
    meta = blue

您可以在git-config参考资料中的中浏览各种color.设置,以获取更多可能的设置. color.diff.meta设置在此处列出:

You can look through the various color. settings in the git-config reference for more possible settings. The color.diff.meta setting is listed here:

color.diff.<slot>
使用自定义颜色进行diff着色. <slot>指定修补程序的哪个部分使用指定的颜色,并且是plain(上下文文本),meta(tainmentformation),frag(大块头),func(大块头中的函数)之一),old(删除的行),new(添加的行),commit(提交标头)或whitespace(突出显示空白错误).这些变量的值可以在color.branch.<slot>中指定.

color.diff.<slot>
Use customized color for diff colorization. <slot> specifies which part of the patch to use the specified color, and is one of plain (context text), meta (metainformation), frag (hunk header), func (function in hunk header), old (removed lines), new (added lines), commit (commit headers), or whitespace (highlighting whitespace errors). The values of these variables may be specified as in color.branch.<slot>.

这篇关于如何在git diff中自定义diff标头的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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