Git Changelog

Learn via video courses
Topics Covered

Overview

If you are a developer then Git is part of your daily life, and so is committing new changes to your projects. If you want to share the changes you have made in your projects with your users or with your fellow developers then you have to maintain a log of all the changes you have made. The file that records all the changes is known as the changelog.

Pre-requisite

Before learning changelog, you should know how to write good commit messages and follow Git guidelines.

What is Changelog?

A changelog is a file that contains a list of all the changes you've made to your project, organized chronologically. A summary of the features that have been added, enhanced, and deleted is frequently listed after the version number and date. Usually, this file is named CHANGE .md and can be found in the project repository.

According to wikipidea: A changelog is a log or record of all notable changes made to a project. The project is often a website or software project, and the changelog usually includes records of changes such as bug fixes, new features, etc.”

We can create a changelog in the following two ways:

  • By copying and pasting the beautified git log message into your CHANGELOG .md This is a straightforward way and doesn't have any pre-requisite.
  • Using advanced auto changelog generators.

Why is It Important?

Users of the product and developers that are working on that product both need to know how the product they are using is evolving. The changelog file gives the above information to the users and the developers.

If the project is open source, then it becomes more important for it to have a changelog file. As many developers work on an open-source project, every contributor should know the major changes that are made to the project.

It is always a good idea to maintain a record of all the major changes, updates, and modifications done.

How to Create Git Changelog?

Apart from manually creating your Git Changelog, there are two more ways:

1. Use Git log

2. Use Automation tools

Using Git Log

This method is straightforward and doesn't need any prerequisites. You just have to type a few Git commands in your terminal and your Git changelog will be ready.

Although you don't require any complex Git knowledge for this method, you still need knowledge of basic Git commands like git log and its options.

The git log command can take a few parameters. We are going to use these parameter options to change the output that we get from git log and get an improved one to generate our changelog.

Command

Example

Using Git Log

In the above image, we can see that after running the above command, we get a list of commits made in the project. We can use these commits to create our Git changelog.

To directly paste the data returned from the above command into a CHANGELOG .md file use the following command:

Using Automation Tools

This method is a sophisticated way to generate a Git changelog. Here, we use tools that can automatically generate our changelog from our well-structured commit message.

However, there are a few things that we need to keep in mind while using these automation tools. The most important one is that we should follow the Git commit guidelines while making commits and writing commit messages. Every automation tool has its guidelines, so make sure to read them before using them.

In this article, we’re using a simple changelog generator that works with most of the guidelines. Its name is generate-changelog, and it’s available on NPM.

Note: To use this tool, you need NPM and node.js installed on your system.

Installation

Type the following command in your terminal:

This command will install the changelog generator on your system globally and you'll be able to use it anywhere on your system.

How to use it?

To use this changelog generator, you need to follow guidelines while writing commit messages. In this example, we'll use the Angular.js project commit guidelines. Your commit message should look like this - type(category): description [flags]

Now, to automatically generate the Git changelog use the following command in your terminal:

This command will generate a CHANGELOG .md file in your folder. Below is an example of a changelog generated from this tool.

Using Automation Tools

Conclusion

I hope you understood what is Git changelog and how you can generate one for your project, using:

  • The Git log
  • The automation tools

It's recommended that you write your commit messages according to a guideline. This will help you generate a changelog automatically.