gpt4 book ai didi

git - git-log 中的颜色

转载 作者:IT王子 更新时间:2023-10-29 01:23:59 25 4
gpt4 key购买 nike

当您运行 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"

最佳答案

从 git 1.8.3(2013 年 5 月 24 日)开始,可以使用 %C(auto) 修饰 格式字符串中的 %d git 日志.

来自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 - git-log 中的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5889878/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com