我如何只显示自 Git 中的标签以来的名称和提交标题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2941567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I show just the names and commit titles since a tag in Git?
提问by Christopher Pickslay
I'm trying to use tags for release management in Git—I create a tag for each release. I'd like to be able to create release notes by listing the comment titles for every commit since a tag, or between 2 tags. I can't seem to find any way to do this.
我正在尝试在 Git 中使用标签进行发布管理——我为每个发布创建了一个标签。我希望能够通过列出自一个标签或两个标签之间的每个提交的评论标题来创建发行说明。我似乎找不到任何方法来做到这一点。
回答by Dominic Cooney
If your tags are named LastRelease
and NextRelease
then do
如果您的标签已命名LastRelease
,NextRelease
然后执行
git log --pretty=format:%s LastRelease..NextRelease
.
git log --pretty=format:%s LastRelease..NextRelease
.
回答by Igor Zevaka
To show commits since TAG to current head:
显示从 TAG 到当前头部的提交:
git log TAG..HEAD
Between two commits:
在两次提交之间:
git log TAG..TAG
For formatting the log output have a look at Pretty formats section of git log.
要格式化日志输出,请查看git log 的漂亮格式部分。
回答by Jason Axelson
You should look into git shortlog
. Here's an example of the output:
你应该调查一下git shortlog
。下面是一个输出示例:
$ git shortlog
Al Jones (512):
Added to .gitignore file
Updated user model
Bob Smith (222):
Minor tweak to view
Updated accounts controller
Charles West (321):
Started specs for user model
Finished specs for user model
For your case you would want to run git shortlog LastRelease..NextRelease
对于您的情况,您希望运行 git shortlog LastRelease..NextRelease
回答by Terrence
I combined Dominic's and Igor's answers together to return the titles of all commits from 2b150c4 to the current HEAD in chronological order and prints it to Terminal (echo
added because git log
doesn't line break the last line).
我将 Dominic 和 Igor 的答案结合在一起,将所有提交的标题按时间顺序从 2b150c4 返回到当前 HEAD 并将其打印到终端(echo
添加是因为git log
没有换行打破最后一行)。
git log --pretty=format:%s 2b150c4..HEAD --reverse | cat; echo
回答by Patrik_P
In order to get detailed infos on commit with a certain (known) message, I firstly call git log --oneline
for overview of commints with messeges and then by the identified SHA view the commit with git show <SHA>
or git log --stat -p <SHA>
为了通过某个(已知)消息获得有关提交的详细信息,我首先调用git log --oneline
带有消息的提交概述,然后通过识别的 SHA 查看提交git show <SHA>
或git log --stat -p <SHA>