git-cliff: Automatically Generate Changelog Files from Git History
git-cliff is a command‑line tool that parses Git commit history using regular expressions or conventional commit conventions to automatically generate customizable changelog files, supporting various installation methods, usage options, and TOML/YAML configuration for fine‑grained control over output.
git-cliff generates changelog files from Git history by parsing normal commit records or using regex‑based custom parsers, allowing the changelog template to be customized via a configuration file to match the desired format.
Similar projects include git-journal, clog-cli, relnotes, and cocogitto.
Project URL: https://github.com/orhun/git-cliff
Installation
From crates.io
cargo install git-cliffUsing pacman
pacman -S git-cliffBuild from source
# linux 下依赖 zlib,生成的文件存放在 `target/release/git-cliff` 目录
CARGO_TARGET_DIR=target cargo build --releaseUsage
Command format
git-cliff [FLAGS] [OPTIONS] [RANGE]Examples
Generate a default configuration file:
git cliff --initGenerate a changelog in the project root:
# 等价于 `git-cliff --config cliff.toml --repository .`
# 等价于 `git-cliff --workdir .`
git cliffTag a release:
git cliff --tag 1.0.0Generate a changelog for a specific range or tag:
# 为 latest tag 生成 changelog
git cliff --latest
# 为未发布的内部生成 changelog
git cliff --unreleased
git cliff --unreleased --tag 1.0.0
# 为指定的某个 commit 生成 changelog
git cliff 4c7b043..a440c6e
git cliff 4c7b043..HEAD
git cliff HEAD~2..Generate a changelog for a specific directory:
git cliff --commit-path project1/Save the changelog to a file:
git cliff --output CHANGELOG.mdPrepend new changes to an existing changelog:
git cliff --unreleased --tag 1.0.0 --prepend CHANGELOG.mdConfiguration File
The configuration file supports TOML (preferred) and YAML formats. If $HOME/git-cliff/cliff.toml exists, it is read; locations differ per platform (Linux, Windows, macOS).
changelog section
[changelog]
header = "Changelog"
body = ""
trim = true
footer = "
"header – title of the changelog
body – template for the changelog body
trim – removes leading/trailing whitespace when true
footer – footer text for the changelog
git section
[git]
conventional_commits = true
commit_parsers = [
{ message = "^feat", group = "Features" },
{ message = "^fix", group = "Bug Fixes" },
{ message = "^doc", group = "Documentation" },
{ message = "^perf", group = "Performance" },
{ message = "^refactor", group = "Refactor" },
{ message = "^style", group = "Styling" },
{ message = "^test", group = "Testing" },
]
filter_commits = false
tag_pattern = "v[0-9]*"
skip_tags = "v0.1.0-beta.1"When conventional_commits is true, commits are parsed according to the Conventional Commits specification ( link ), which provides a lightweight convention for clear commit histories and aids automated tooling.
Commit parsers use regular expressions to group commits, e.g., messages starting with feat are grouped under "Features"; commits containing "security" in the body are grouped under "Security"; and commits marked with revert are skipped.
Additional options include filter_commits to exclude non‑matching commits, tag_pattern for matching tag names (e.g., v[0-9]* ), and skip_tags to ignore specific tags.
Sohu Tech Products
A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.