TExcelTAD
Home › Release Engineering & CI/CD › Changelogs with git-cliff

Changelogs with git-cliff

git-cliff is a changelog generator written in Rust: one static binary, no runtime, configured by a cliff.toml file with Tera templates. It reads your Git history, parses Conventional Commits, groups them, and renders Markdown (or anything else). It can also compute the next version. The sessions use git-cliff 2.14.2.

The first changelog

Every session starts from a small history with one release tag. The function c makes a commit with the given message:

bash · try it yourself
mkdir lib && cd lib && git init -q
c() { echo "$1" >> log.txt; git add log.txt; git commit -q -m "$1"; }
c "feat: parse config files"
c "docs: add a README"
git tag -a v0.1.0 -m "v0.1.0"
c "fix(parser): accept empty lines"
c "feat(cli): add --quiet"
c "chore: update CI image"
c "perf: cache parsed files"
c "Merge the experiments"
git-cliff --init
git-cliff 2>warnings.txt
echo "--- stderr:"
sed 's/\x1b\[[0-9;]*m//g' warnings.txt
## [unreleased]

### 🚀 Features

- *(cli)* Add --quiet

### 🐛 Bug Fixes

- *(parser)* Accept empty lines

### ⚡ Performance

- Cache parsed files

### ⚙️ Miscellaneous Tasks

- Update CI image
## [0.1.0] - 2026-01-15

### 🚀 Features

- Parse config files

### 📚 Documentation

- Add a README
--- stderr:
WARN  git_cliff_core::changelog > 1 commit(s) were skipped due to parse error(s) (run with `-vv` for details)

What happened:

  • git-cliff --init wrote the default cliff.toml (without it, git-cliff uses the same defaults but warns on stderr).
  • Commits since the last tag are under [unreleased]; the tagged ones are under [0.1.0] with the tag's date. The date is 2026-01-15 because every commit in these sessions has that date.
  • Commits were grouped by type into sections with emoji headings, and the scope is shown in italics.
  • Merge the experiments is missing: it isn't a Conventional Commit, and the default config sets filter_unconventional = true. The only trace is a warning on stderr (git-cliff colours it; sed strips the colour codes here). The next lesson makes such commits visible or fails the run on them.

The everyday options

Option What it does
-o CHANGELOG.md write to a file instead of stdout
-u, --unreleased only commits after the latest tag
-l, --latest only the latest tagged release
--current only the release the current commit's tag belongs to
-t v1.0.0, --tag v1.0.0 treat unreleased commits as this version (before the tag exists)
--bump like --tag, but compute the version from the commits
--bumped-version only print the computed version
-p CHANGELOG.md, --prepend add the new section to the top of an existing file (use with -u)
--strip header / --strip all drop the header (and footer): handy for release notes
RANGE (e.g. v0.1.0..HEAD) an explicit commit range
--include-path 'packages/core/**' only commits touching those paths (monorepos)
-x, --context print the data the template receives, as JSON

Computing the next version

--bumped-version reads the commits since the latest tag and applies the SemVer rules from the Conventional Commits lesson. --bump uses the result as the version heading:

bash · try it yourself
mkdir lib && cd lib && git init -q
c() { git commit -q --allow-empty -m "$1"; }
c "feat: first release"
git tag -a v1.3.0 -m "v1.3.0"
c "fix: handle a missing HOME"
echo "after a fix:          $(git-cliff --bumped-version 2>/dev/null)"
c "feat(api): add a timeout option"
echo "after a feature:      $(git-cliff --bumped-version 2>/dev/null)"
git commit -q --allow-empty -m "refactor(api)!: rename Client to Session" -m "BREAKING CHANGE: Client is now Session."
echo "after a breaking one: $(git-cliff --bumped-version 2>/dev/null)"
git-cliff --bump --unreleased --strip header 2>/dev/null
after a fix:          v1.3.1
after a feature:      v1.4.0
after a breaking one: v2.0.0
## [2.0.0] - 2026-10-23

### 🚀 Features

- *(api)* Add a timeout option

### 🐛 Bug Fixes

- Handle a missing HOME

### 🚜 Refactor

- *(api)* [**breaking**] Rename Client to Session

The heading's date is today (the day the changelog is generated), because the release hasn't been tagged yet. Once you tag v2.0.0, regenerating uses the tag's commit date. Release tools behave the same way.

A release with git-cliff and Git only

git-cliff doesn't create tags or commits; it only writes text. The rest is a few lines of shell, and that is the whole release logic many projects need. Here the remote is a bare repository:

bash · try it yourself
git init -q --bare remote.git
git clone -q remote.git lib 2>/dev/null && cd lib
c() { git commit -q --allow-empty -m "$1"; }
c "feat: first release"; git tag -a v1.0.0 -m "v1.0.0"
git-cliff --init >/dev/null 2>&1
git-cliff -o CHANGELOG.md
git add CHANGELOG.md cliff.toml && c "chore(release): add changelog"
git push -q origin main v1.0.0
c "fix: trim trailing whitespace"
c "feat: add --version"

next=$(git-cliff --bumped-version)
git-cliff --bump --unreleased --prepend CHANGELOG.md
git-cliff --bump --unreleased --strip all > release-notes.md
git add CHANGELOG.md
git commit -q -m "chore(release): $next"
git tag -a "$next" -m "Release $next"
git push -q origin main "$next"

echo "released $next"
git log --format='%s%d' -3   # no hashes: the release commit's changelog holds today's date
echo "--- CHANGELOG.md"
cat CHANGELOG.md
echo "--- release-notes.md"
cat release-notes.md
released v1.1.0
chore(release): v1.1.0 (HEAD -> main, tag: v1.1.0, origin/main)
feat: add --version
fix: trim trailing whitespace
--- CHANGELOG.md
## [1.1.0] - 2026-10-24

### 🚀 Features

- Add --version

### 🐛 Bug Fixes

- Trim trailing whitespace

### ⚙️ Miscellaneous Tasks

- *(release)* Add changelog
## [1.0.0] - 2026-01-15

### 🚀 Features

- First release
--- release-notes.md
## [1.1.0] - 2026-10-24

### 🚀 Features

- Add --version

### 🐛 Bug Fixes

- Trim trailing whitespace

### ⚙️ Miscellaneous Tasks

- *(release)* Add changelog

The order matters: compute the version, write the changelog and the release notes (the same section without a header, for the GitHub Release body), commit, then tag that commit, so the tag contains its own changelog entry. Notice that chore(release): add changelog appears under 1.1.0's "Miscellaneous Tasks": the default config only skips messages starting with chore(release): prepare for. Matching your release-commit message to a skip parser is one of the first config changes in the next lesson.

The Node.js counterpart: conventional-changelog

In JavaScript projects you will also meet conventional-changelog, the library behind semantic-release's notes, with its own CLI (conventional-changelog 7.2.1 here; the older conventional-changelog-cli package is deprecated). It works from presets instead of a template file, and it doesn't compute a version: it labels the unreleased commits with the version from package.json, which npm version or a release tool has already bumped. Here is the history from "Computing the next version", plus a docs: commit:

bash · try it yourself
mkdir lib && cd lib && git init -q
c() { git commit -q --allow-empty -m "$1"; }
cat > package.json <<'JSON'
{ "name": "lib", "version": "1.3.0", "repository": "https://github.com/acme/lib" }
JSON
git add package.json && c "feat: first release" && git tag -a v1.3.0 -m "v1.3.0"
c "fix: handle a missing HOME"
c "feat(api): add a timeout option"
git commit -q --allow-empty -m "refactor(api)!: rename Client to Session" -m "BREAKING CHANGE: Client is now Session."
c "docs: explain the timeout option"
npm pkg set version=2.0.0
conventional-changelog -p conventionalcommits --stdout
## [2.0.0](https://github.com/acme/lib/compare/v1.3.0...v2.0.0) (2026-10-24)

### ⚠ BREAKING CHANGES

* **api:** Client is now Session.

### Features

* **api:** add a timeout option ([ea2e467](https://github.com/acme/lib/commit/ea2e467808a38bc7fbb5e15877ad43c7614b59ff))

### Bug Fixes

* handle a missing HOME ([5364ce5](https://github.com/acme/lib/commit/5364ce594e48a77e4dd0f208f9f5b12f0346a42b))

### Code Refactoring

* **api:** rename Client to Session ([ae40cbf](https://github.com/acme/lib/commit/ae40cbf4e00b3ff1bd912d978e31eaf84a354c14))

Compared with git-cliff's default output: the docs commit is hidden (the preset shows features, fixes, performance improvements and reverts, plus any commit marked breaking, which is why the refactor appears), the footer's text leads the ⚠ BREAKING CHANGES section, and the links are built from repository in package.json. Without --stdout the CLI prepends the new section to CHANGELOG.md, and -r 0 regenerates every release. The preset is pinned to a matching conventional-changelog-writer version, as the semantic-release lesson explains. Choose git-cliff when you want one binary and full control of the template, conventional-changelog when your release tooling is already Node-based and you want its notes and your changelog to match.

Test yourself

A commit Merge the experiments is missing from git-cliff's output. Why?

  1. git-cliff ignores merges
  2. It isn't a Conventional Commit and the default filter_unconventional = true drops it
  3. It has no scope
  4. It was committed after the tag

Which command prints only the next version, computed from unreleased commits?

  1. git-cliff --latest
  2. git-cliff --bumped-version
  3. git-cliff --tag
  4. git-cliff --current

Why commit the changelog before creating the release tag?

  1. git-cliff requires a clean tree
  2. So the tagged commit contains its own changelog entry
  3. Tags can't point at changelog commits
  4. To trigger CI twice

Where does the conventional-changelog CLI get the version for the unreleased commits?

  1. It computes it from the commit types
  2. From version in package.json, bumped beforehand by npm version or a release tool
  3. From the newest tag plus one
  4. From the --bump flag