LinuxCommandLibrary

git-changelog

Generate a changelog from Git history

TLDR

Update existing file or create a new History.md file with the commit messages since the latest Git tag

$ git changelog
copy

List commits from the current version
$ git changelog [[-l|--list]]
copy

List a range of commits from the tag named 2.1.0 to now
$ git changelog [[-l|--list]] [[-s|--start-tag]] [2.1.0]
copy

List pretty formatted range of commits between the tag 0.5.0 and the tag 1.0.0
$ git changelog [[-s|--start-tag]] [0.5.0] [[-f|--final-tag]] [1.0.0]
copy

List pretty formatted range of commits between the commit 0b97430 and the tag 1.0.0
$ git changelog --start-commit [0b97430] [[-f|--final-tag]] [1.0.0]
copy

Specify CHANGELOG.md as the output file
$ git changelog [CHANGELOG.md]
copy

Replace contents of current changelog file entirely
$ git changelog [[-p|--prune-old]]
copy

SYNOPSIS

git changelog [options] [range]

PARAMETERS

--format <fmt>
    Specifies the output format for the changelog, e.g., markdown, json, html.

--output <file>
    Writes the generated changelog to the specified file instead of standard output.

--tag-range <tag1>..
    Generates the changelog for commits between two specified Git tags.

--since <date>
    Includes commits more recent than the specified date or commit hash.

--until <date>
    Includes commits older than the specified date or commit hash.

--no-merges
    Excludes merge commits from the generated changelog output.

--scope <scope>
    Filters commits by a specific scope, often used with Conventional Commits patterns.

--config <file>
    Specifies an alternative configuration file for the changelog generation process.

--help
    Displays a help message and exits.

--version
    Displays the version information of the changelog tool and exits.

DESCRIPTION

The git-changelog command is a powerful utility designed to automate the creation of project changelogs directly from a Git repository's commit history. It parses commit messages, tags, and branches to compile a structured, human-readable log of changes between specified versions or dates.

Instead of manually compiling release notes, git-changelog tools analyze the commit graph, categorize changes (e.g., features, bug fixes, breaking changes) based on conventional commit messages (like Conventional Commits or Semantic Release conventions), and format them into a consistent output, often Markdown. This automation significantly reduces the effort required for release management, ensures accuracy, and promotes consistent documentation across releases.

It's particularly useful in Continuous Integration/Continuous Deployment (CI/CD) pipelines, where a changelog can be automatically generated upon new releases or merges to the main branch. The tool can be configured to filter commits by author, date range, or specific tags, and to customize the output format to integrate seamlessly with project documentation.

CAVEATS

The effectiveness and accuracy of git-changelog tools are highly dependent on consistent and well-structured Git commit messages. Adherence to conventions like Conventional Commits is crucial for automatic categorization and filtering. git-changelog is not a built-in Git command; it typically refers to third-party tools or scripts that need to be installed separately. Behavior and options can vary significantly between different implementations.

COMMIT MESSAGE CONVENTIONS

For optimal results, git-changelog tools highly recommend following a structured commit message convention, such as Conventional Commits. These conventions define a standard format for commit messages (e.g., feat(scope): add new feature, fix(auth): resolve login bug), enabling the changelog generator to automatically categorize changes into sections like 'Features', 'Bug Fixes', 'Breaking Changes', etc. Without consistent conventions, the tool's ability to produce a well-organized and meaningful changelog is significantly limited.

INTEGRATION WITH CI/CD

git-changelog commands are frequently integrated into Continuous Integration/Continuous Deployment (CI/CD) pipelines. This allows for automated changelog generation as part of the build or release process. For instance, a new changelog entry can be appended to a CHANGELOG.md file, or a full changelog generated and published, whenever a new version is tagged or a release branch is merged. This automation ensures that documentation is always up-to-date with releases without manual intervention.

HISTORY

The concept of automatically generating changelogs from Git history emerged from the need to streamline release processes and improve documentation consistency. Initially, changelogs were often compiled manually, a tedious and error-prone task. As Git became the dominant version control system, developers sought ways to leverage its rich commit history. This led to the development of various independent scripts and tools, often named git-changelog, across different programming languages (e.g., Python, Node.js, Ruby, Go). These tools typically abstract away the complexities of parsing git log output, applying rules for categorization, and formatting into standard documentation formats. Their evolution is closely tied to the rise of conventions like Conventional Commits and the adoption of CI/CD practices, making automated changelog generation an integral part of modern software development workflows.

SEE ALSO

git log(1), git tag(1), git shortlog(1), git(1)

Copied to clipboard