【问题标题】:Set pretty format for git log only仅为 git log 设置漂亮的格式
【发布时间】:2019-11-16 15:31:25
【问题描述】:

我发现默认的漂亮格式是冗长的,所以我制作了更简洁的版本:

[format]
    pretty = %C(yellow)commit:   %h%Creset%C(auto)%d%C(reset)%nauthor:   %an <%ae>%ndate:     %ad%nsummary:  %s%n

产生类似的东西:

commit:   ab6cdf4 (HEAD -> master, tag: v1.1)
author:   author name <author@email.com>
date:     Fri Nov 15 22:00:00 2019 +0100
summary:  A very nice commit title

第一行的颜色和往常一样。

但是,这不仅会影响git log,还会影响git show,对于git show,我实际上更愿意使用mediumfuller 格式。

有没有办法只为git log 设置格式?也许通过format.pretty以外的其他选项。

一个明显的解决方案是使用 other 格式为 logshow 的版本创建别名,但如果可能的话,我宁愿避免这样做。

【问题讨论】:

    标签: git


    【解决方案1】:

    考虑到git config format.pretty 总是 代表git log (configuration) git show,我一直为 git log 定义一个别名。

    例如:

    因此,在这种情况下,别名可能仍然是当前推荐的解决方法。

    【讨论】:

      猜你喜欢
      • 2017-06-30
      • 1970-01-01
      • 2021-03-30
      • 2021-02-28
      • 2013-03-05
      • 2019-07-16
      • 1970-01-01
      • 2020-04-28
      • 2019-04-02
      相关资源
      最近更新 更多