标签之间的 Git 日志
我正在尝试输出两个标记提交之间的日志。
mbell@cheetah [12:07:22] [/var/www/html/brone] [dev]
-> % git tag
6.x-0.1
6.x-1.0-beta1
6.x-1.0-beta2
6.x-1.0-beta3
6.x-1.0-beta4
6.x-1.0-beta5
6.x-1.0-beta6
6.x-1.0-beta7
6.x-1.0-beta8
6.x-1.0-beta9
如果我这样做:
git log 6.x-1.0-beta8 6.x-1.0-beta9 > ~/gitlogbrone.txt
它输出自存储库启动以来的所有提交,这不是我想要的。我已经阅读了 git log 手册,但没有多大帮助。
I'm trying to output the log between two tagged commits.
mbell@cheetah [12:07:22] [/var/www/html/brone] [dev]
-> % git tag
6.x-0.1
6.x-1.0-beta1
6.x-1.0-beta2
6.x-1.0-beta3
6.x-1.0-beta4
6.x-1.0-beta5
6.x-1.0-beta6
6.x-1.0-beta7
6.x-1.0-beta8
6.x-1.0-beta9
If I then do:
git log 6.x-1.0-beta8 6.x-1.0-beta9 > ~/gitlogbrone.txt
It outputs all the commits since the start of the repo which isn't what I want. I've read through the git log manual but it's not helping much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您需要一个省略号来指示范围。尝试
git log tag1..tag2
。You need an ellipsis to indicate a range. Try
git log tag1..tag2
.对于那些有兴趣生成发行说明文件并想要一个可读且易于修改的脚本的人来说,对 @Yurii 和 @wilmol 的答案进行了扩展。
An expansion on the answers from @Yurii and @wilmol for those interested in generating a release notes file and wanting a script that is readable and easily modified.
The above script generates a markdown file at
release_notes.md
that looks like this:???? Release notes (
14.2
)Changes
Metadata
I like this approach for a few reasons:
If there is a tag between the two tags I'm interested in, I can manually set
$VERSION
and$PREVIOUS_VERSION
before running the last two lines.With a few tweaks, I can sort, filter, and modify
$CHANGES
to meet my specific needs.我用它来获取最后两个标签之间的提交:
I use this to get the commits between the last 2 tags:
感谢 @Noufal Ibrahim 的回答。
我正在提交一个文件并创建一个新标签。但在此之前,我需要列出并格式化最后一个标签创建后的所有提交。这是我当时所做的:
Thanks to @Noufal Ibrahim for his answer.
I was committing a file and creating a new tag. But before doing that, my need was to list and format all of the commits after the last tag created. Here is what I did that time:
@wilmol 的一个稍微优化的解决方案,
我更喜欢在版本注释的脚本中使用以下代码:
这个代码给出了最后两个标签之间的清晰提交历史记录,没有 git has 和合并行。
A bit optimised solution from @wilmol
I prefer to use in scripts for the release notes the following code:
This one give a clear commits history between two last tags without git has and merge lines.
我正在使用以下快捷方式
git log $(git tag |tail -1)..
I'm using the following shortcut
git log $(git tag |tail -1)..