【问题标题】:How to print initial letter of committer in git log?如何在 git log 中打印提交者的首字母?
【发布时间】:2016-12-10 21:25:23
【问题描述】:

我已经准备了一个别名,以便在 git 中获取简短的日志报告

# excerpt from ~/.gitconfig
[alias]
    lg = log --all --oneline --graph --decorate --pretty='%C(auto)%h %Cgreen%ai %C(reset)%C(auto)%s %d'

git lg 每次提交都会生成一个不错的行,但没有关于用户的信息:

* 623beff 2016-11-14 14:18:36 +0100 extended plotstyle option and automatic colors

或截图:

但是我想在每一行看到提交者真实姓名的首字母(全名有时太长):

* 623beff 2016-11-14 14:18:36 +0100 (J.S.) extended plotstyle option and automatic colors

我怎样才能得到这个结果?

【问题讨论】:

    标签: regex git logging configuration pretty-print


    【解决方案1】:

    有一种方法可以获取名字的第一个字母,使用%<(3,trunc)%cN

    git log --all --oneline --graph --decorate --pretty='%C(auto)%h %Cgreen%ai %C(reset)%C(auto)(%<(3,trunc)%cN) %s %d'
    

    输出:

    * 8759307 2009-01-15 16:11:48 +0000 (S..) Remove spurious code trying to tag a branch root before the mark was created.  (HEAD -> master, origin/master, origin/HEAD)
    * 939f999 2008-12-11 13:41:37 +0000 (S..) When just writing output file, do not try to devise lock target with no repository.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-07
      • 1970-01-01
      • 1970-01-01
      • 2011-03-22
      • 2014-09-07
      • 2015-04-02
      • 2015-03-08
      相关资源
      最近更新 更多