---
title: git-cliff - 高可定制的 Git 项目变更日志生成器：从代码提交中自动生成变更日志
date: 2024-07-14T07:43:14Z
modified: 2024-07-14T07:43:22Z
permalink: "https://www.appinn.com/git-cliff/"
type: post
status: publish
excerpt: ""
categories:
  - 实用工具
tags:
  - 实用工具
  - Git
  - 开发者
featured_image: "https://www.appinn.com/wp-content/uploads/2024/07/Appinn-feature-images-2024-07-14T150805.457.jpg"
author: 青小蛙
timestamp: 2024-07-14T07:43:22Z
---

**git-cliff** 是一个可以从 Git 历史记录中自动生成变更日志的小工具，并且能通过模板定义格式内容，最终导出 CHANGELOG.md 文件。@[Appinn](https://www.appinn.com/git-cliff.md)

![git-cliff - 高可定制的 Git 项目变更日志生成器：从代码提交中自动生成变更日志](https://www.appinn.com/wp-content/uploads/2024/07/Appinn-feature-images-2024-07-14T150805.457.jpg)

## git-cliff 如何使用

git-cliff 能够整合在 `git` 之中，使用的时候只需要：

`git cliff --output CHANGELOG.md`

它会根据 git 提交记录，匹配如 fix｜修复、doc｜文档、style｜样式、perf｜性能 等描述语，然后自动生成 .md 文档。

[默认文档](https://github.com/orhun/git-cliff/blob/main/config/cliff.toml)匹配是这样的，按需修改即可。


  { message = "^feat", group = "<!-- 0 -->🚀 Features" },
  { message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
  { message = "^doc", group = "<!-- 3 -->📚 Documentation" },
  { message = "^perf", group = "<!-- 4 -->⚡ Performance" },
  { message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
  { message = "^style", group = "<!-- 5 -->🎨 Styling" },
  { message = "^test", group = "<!-- 6 -->🧪 Testing" },
  { message = "^chore\\(release\\): prepare for", skip = true },
  { message = "^chore\\(deps.*\\)", skip = true },
  { message = "^chore\\(pr\\)", skip = true },
  { message = "^chore\\(pull\\)", skip = true },
  { message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
  { body = ".*security", group = "<!-- 8 -->🛡️ Security" },
  { message = "^revert", group = "<!-- 9 -->◀️ Revert" },




可以为特定的部分 git 历史记录生成变成日志，比如：


```
git cliff --current<br></br>git cliff --unreleased --tag 1.0.0
```

也可以指定范围：


```
git cliff 4c7b043..a440c6e<br></br>git cliff 4c7b043..HEAD<br></br>git cliff HEAD~2..<br></br>git cliff v2.2.1..<br></br>git cliff v0.1.0..HEAD
```

更具体的用法[参见例子](https://git-cliff.org/docs/usage/examples)。

## 获取

- [官网](https://git-cliff.org/)

有需求的同学可以试试。

具体的案例，可以 git-cliff 自己的 [CHANGELOG.md](https://github.com/orhun/git-cliff/blob/main/CHANGELOG.md) 文件。

---

原文：https://www.appinn.com/git-cliff/

## Topics

**分类目录:** [实用工具](https://www.appinn.com/category/tools/?output_format=md)

**标签:** [Git](https://www.appinn.com/tag/git/?output_format=md), [开发者](https://www.appinn.com/tag/%e5%bc%80%e5%8f%91%e8%80%85/?output_format=md)