git-log中的颜色 [英] Color in git-log
本文介绍了git-log中的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当运行 在我的gitconfig中我也有以下内容: git log --decorate --pretty = oneline
时,输出将会包含之类的条目(HEAD,refs / published / master, )
[colorbranch]
current = yellow reverse
local = yellow
remote = green
如何在执行下列自定义格式时复制这些颜色?
git log --decorate --stat --graph --pretty = format:%d%Cgreen%h%Creset(%ar - %Cred%and%Creset),%s%n
解决方案
从git 1.8.3开始(2013年5月24日) ,您可以使用%C(auto)
来修饰格式字符串中的
。%d
git log
从版本说明:
*git log --format %b(auto)令牌告诉Git
在插入%d(装饰),%h(短提交
对象名称)等终端输出时使用颜色。)
code>
When you run git log --decorate --pretty=oneline
the output will have entries like (HEAD, refs/published/master, master)
with coloration.
I also have the following in my gitconfig:
[color "branch"]
current = yellow reverse
local = yellow
remote = green
How do you replicate those colors when doing a custom format like the following?
git log --decorate --stat --graph --pretty=format:"%d %Cgreen%h%Creset (%ar - %Cred%an%Creset), %s%n"
解决方案
As of git 1.8.3 (May 24, 2013), you can use %C(auto)
to decorate %d
in the format string of git log
.
From the release notes:
* "git log --format" specifier learned %C(auto) token that tells Git
to use color when interpolating %d (decoration), %h (short commit
object name), etc. for terminal output.)
这篇关于git-log中的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文