如何模拟git log - 为每个分支类型设置不同的颜色 [英] How to emulate git log --decorate's different colors per branch-type

查看:229
本文介绍了如何模拟git log - 为每个分支类型设置不同的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在制作我最喜欢的git log视图时,我创建了这个别名:

graph = log --pretty = format:'%Cgreen %广告%CRESET%C(黄色)%H%CRESET%C(黄色)%d%CRESET%S%C(青色)[%的]%CRESET%Cgreen(%AR)%CRESET --date =短 - -graph



这会创建一个输出:



我在这里错过的是不同颜色的分支类型如 log --oneline --decorate --graph





-decorate(默认使用= short)为不同的识别分支提供不同的颜色。分支类型(HEAD,origin / master,origin / HEAD,master)为青色,红色,红色,绿色。然而,我的是无色的;只用整个分支部分的黄色着色。



有没有办法给不同的种类的分支提供不同的颜色有自己的别名? https://stackoverflow.com/a/16844346/55948


从git 1.8.3开始(2013年5月24日),您可以使用%C(auto)装饰
%d in格式字符串 git log



  *git log --format说明符已学习%C(自动)令牌,告知Git 
在插入%d(装饰),%h(短提交
$对象名称)等等)。



In making my favorite git log view I've created this alias:

graph = log --pretty=format:'%Cgreen%ad%Creset %C(yellow)%h%Creset%C(yellow)%d%Creset %s %C(cyan)[%an]%Creset %Cgreen(%ar)%Creset' --date=short --graph

This creates an output like:

What I'm missing here is the different coloring of branch types like in log --oneline --decorate --graph.

The --decorate (which uses =short by default) gives the different recognized branches a different color. The branch types (HEAD, origin/master, origin/HEAD, master) are colored cyan, red, red, green. Mine however are uncolored; colored only with the yellow of the whole branches part.

Is there a way to give different colors to the different kind of branches with an own alias?

解决方案

Per https://stackoverflow.com/a/16844346/55948

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屋!

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