The git-cliff is a command line tool for generating changelogs from Git commit history. It automatically extracts relevant commit messages and formats them into a structured changelog. This helps developers maintain clear and consistent release notes with minimal effort. This tutorial explains how to install git-cliff on Ubuntu 24.04.
Prepare environment
Make sure Git is installed on your system. You can refer to a post on how to install it.
Install git-cliff
Get the latest release version of git-cliff from its official GitHub repository and store it in a variable:
GIT_CLIFF_VERSION=$(curl -s "https://api.github.com/repos/orhun/git-cliff/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
Download git-cliff using the previously retrieved version:
wget -qO git-cliff.tar.gz https://github.com/orhun/git-cliff/releases/latest/download/git-cliff-$GIT_CLIFF_VERSION-x86_64-unknown-linux-gnu.tar.gz
Create a temporary directory and extract the contents of the tar.gz
file into it:
mkdir git-cliff-temp
tar xf git-cliff.tar.gz --strip-components=1 -C git-cliff-temp
Move the git-cliff
executable to the /usr/local/bin
directory:
sudo mv git-cliff-temp/git-cliff /usr/local/bin
Verify the git-cliff version by executing the following command:
git cliff --version
Finally, delete the temporary directory and the downloaded file:
rm -rf git-cliff.tar.gz git-cliff-temp
Testing git-cliff
Clone the repository and navigate to it:
git clone https://github.com/orhun/git-cliff && cd git-cliff
Initialize git-cliff configuration:
git cliff --init
This generates a default cliff.toml
configuration file. The config file defines how commits are parsed and formatted in the changelog. You can customize this file to change section headings, commit message patterns, output formats, etc.
Generate changelog of the latest tag:
git cliff --latest
This command generates a changelog for the most recent tag and prints output to the terminal. Output example:
# Changelog
All notable changes to this project will be documented in this file.
## [2.8.0] - 2025-01-24
### 🚀 Features
- *(repo)* Allow running from sub directories (#975)
- *(monorepo)* Automatically set include-path for current directory
- *(config)* Discover the configuration file when run in a sub directory
...
Uninstall git-cliff
To remove git-cliff, simply delete its executable file:
sudo rm -rf /usr/local/bin/git-cliff
Leave a Comment
Cancel reply