Git commit messages are crucial. They are used in order to describe with others what you did while working on your projects. Before you can save changes in Git, you have to tell Git which changes you want to save as you might have made tons of edits. A great way to do that is by adding a commit message to identify your changes.

Git commit messages plays a significant part in the life of software developers. Assuming that your git commit messages are perfect and coordinated you can undoubtedly comprehend and allude to past code changes utilizing git commit messages itself. It helps your teammates too to envision the advancement of the feature development or bug fixes easily without any problem.

Regardless of whether developers compose a decent message, many individuals have their own style or way of composing their commit messages. To take care of this specific problem, we will look at utilizing commitizen for all git commits.

What is Commitizen?

Commitizen is a command line tool that helps format commit messages with a series of prompts that are used to generate a commit message. It accomplishes this by prompting them to follow commit message conventions at commit time. It also empowers project maintainers to create or use predefined commit message conventions in their repos to better communicate their expectations to potential contributors.

Why Commitizen?

  • It makes git commit messages clear
  • Consistent message format cross team members
  • Easy to review commit history, new features, break changes, bug fixes etc.
  • Generate a changelog using Keep a changelog.

Installation
macOS
On macOS, it can be installed via homebrew:

Git Commit using Commitizen
After installing commitizen you can run the following command inside your git repository.

It will show the following options.

If you observe there are 9 options that cover most of the activities in software development lifecycle starting from;

    • fix: A bug fix
    • feat: A new feature
    • docs: Documentation only changes
    • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
    • refactor: A code change that neither fixes a bug nor adds a feature
    • perf: A code change that improves performance
    • test: Adding missing or correcting existing tests
    • build: Changes that affect the build system or external dependencies (example scopes: pip, docker, npm)
    • ci: Changes to our CI configuration files and scripts (example scopes: GitLabCI)

Let’s walk through an example, I will select feat to add a new structure to my spring boot application. Look at the steps below;

 

Git log will look like this below.

See how the commit looks on Github, the commit message is very clear with the corresponding use-cases following the rules of Commitizen.
Now you and everyone in your team can easily write beautiful conventional commit messages.
Share: