当您运行git log --decorate --pretty=oneline时,输出将包含像(HEAD, refs/published/master, master)这样的带有颜色的条目。
我的gitconfig中还包含以下内容:
[color "branch"]
current = yellow reverse
local = yellow
remote = green在执行如下自定义格式时,如何复制这些颜色?
git log --decorate --stat --graph --pretty=format:"%d %Cgreen%h%Creset (%ar - %Cred%an%Creset), %s%n"发布于 2013-05-31 03:26:46
从git 1.8.3 (2013年5月24日)开始,可以使用%C(auto)来修饰git log格式字符串中的%d。
* "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.)发布于 2011-05-05 07:02:07
将它们括起来:
%C(...): color specification, as described in color.branch.* config option
这样%C(yellow reverse)就可以工作了。
发布于 2012-03-24 01:51:23
配置选项log.decorate可以启用/禁用日志中的默认修饰。
git config --global log.decorate full完成后,您可以使用color.decorate.*来处理颜色
https://stackoverflow.com/questions/5889878
复制相似问题