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

目录

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

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

参数说明:

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

    • %h 是提交的简短哈希
    • %s 是提交的描述
    • %an 是提交的作者名字
    • %ad 提交日期
  • --date=short 选项下会使用简短的日期格式
    默认的日期格式示例 Sun Oct 6 00:56:25 2024 +0800,简短的日期格式示例 2024-10-06

示例,仅导出日期和提交的摘要
git log --pretty=format:"%ad %s" --date=short > commit_summaries.txt