You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让git log仅显示提交消息?用于编写发布笔记

让git log仅输出提交消息的方法

要让git log只输出提交消息、剔除其他冗余信息,有几种实用的命令组合,完全满足你做发布笔记起点的需求:

  • 只提取提交消息的标题行(大部分提交的核心变更描述):

    git log --pretty=format:"%s"
    

    其中%s是git的格式占位符,代表提交的主题(subject)。

  • 提取完整的提交消息(包含换行和所有内容):

    git log --pretty=format:"%B"
    

    %B对应提交的完整正文(body),适合需要保留详细说明的场景。

  • 若想排除合并分支的提交记录(避免发布笔记混入无意义的合并信息),可以追加--no-merges参数:

    git log --pretty=format:"%s" --no-merges
    

如果需要直接将输出保存到文件方便后续编辑发布笔记,可使用重定向:

git log --pretty=format:"%s" --no-merges > release_notes.md

内容的提问来源于stack exchange,提问作者Keith Bennett

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 04:34:51