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


当前回答

这将为您提供一个非常紧凑的任何指定时间的所有消息列表。

git log --since=1/11/2011 --until=28/11/2011 --no-merges --format=%B > CHANGELOG.TXT

其他回答

它不是“管道”,但它会做你想要的:

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

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

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

尽管rev-list除了提交消息外还会打印出commit sha(在第一行)。

不是管道,但我有这些在我的。gitconfig:

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

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

在git中单独获得我的最后一个提交消息

git log——format=%B -n 1 $(git log -1——pretty=format:"%h") | cat -

我用shortlog来表示:

$ git shortlog master..
Username (3):
      Write something
      Add something
      Bump to 1.3.8 

这将为您提供一个非常紧凑的任何指定时间的所有消息列表。

git log --since=1/11/2011 --until=28/11/2011 --no-merges --format=%B > CHANGELOG.TXT