代码之家  ›  专栏  ›  技术社区  ›  Mark Probst

以Git格式打印给定提交的提交消息

  •  182
  • Mark Probst  · 技术社区  · 15 年前

    我需要一个管道命令来打印一个给定提交的提交消息——不多也不少。

    6 回复  |  直到 6 年前
        1
  •  245
  •   mipadi    15 年前

    这不是“管道”,但它会完全满足您的需要:

    $ git log --format=%B -n 1 <commit>
    

    如果您绝对需要一个“管道”命令(不确定这是为什么需要),您可以使用 rev-list :

    $ git rev-list --format=%B --max-count=1 <commit>
    

    虽然 转速表 除了提交消息外,还将打印出提交sha(在第一行)。

        2
  •  105
  •   CharlesB Craig McQueen    12 年前

    git show 更像是一个管道命令,而不是 git log ,并具有相同的格式选项:

    git show -s --format=%B SHA1
    
        3
  •  15
  •   Justin    13 年前

    这将为您提供任何指定时间内所有消息的非常简洁的列表。

    git log --since=1/11/2011 --until=28/11/2011 --no-merges --format=%B > CHANGELOG.TXT
    
        4
  •  11
  •   bstpierre Edgar Aviles    15 年前

    不是管道,但我的.gitconfig中有:

    lsum = log -n 1 --pretty=format:'%s'
    lmsg = log -n 1 --pretty=format:'%s%n%n%b'
    

    这是“最后的总结”和“最后的信息”。您可以提供一个提交来获取该提交的摘要或消息。(我用的是1.7.0.5,所以没有%b。)

        5
  •  2
  •   mja    6 年前

    我使用短日志:

    $ git shortlog master..
    Username (3):
          Write something
          Add something
          Bump to 1.3.8 
    
        6
  •  0
  •   nos    6 年前

    我开始使用

    git show-branch --no-name <hash>
    

    它似乎比

    git show -s --format=%s <hash>
    

    两者的结果相同

    推荐文章