Git 导出提交摘要到文本文件

如何将所有的 git commits 的描述导出到文本文件?

示例:git log --pretty=format:"%h %an %ad %s" --date=short > commits.txt

参数说明:

  • --pretty=format: 指定输出格式,其中

    • %h 是提交的简短哈希
    • %s 是提交的摘要/标题(summary)
    • %b,提交的描述(body)
    • %n,换行符
    • %an 是提交的作者名字
    • %ad 提交日期
  • --date=short 选项下会使用简短的日期格式
    默认的日期格式示例 Sun Oct 6 00:56:25 2024 +0800,简短的日期格式示例 2024-10-06