How To Improve Your Git Commit Messages Using Conventional Commits

Photo by Yancy Min on Unsplash

How To Improve Your Git Commit Messages Using Conventional Commits

Simple Tips for Enhancing Git Commit Messages

ยท

2 min read

When working with code, explaining to others what we've done in our code is not easy. Writing commit messages to convey our changes can vary for each team member. Everyone has their own way of writing commit messages, and sometimes we don't know what to write in the commits.

Every team member communicates their changes differently, making it difficult to understand what changes have occurred. What if we established a standard or team agreement for writing commit messages?

The solution is to use Conventional Commits.

Conventional Commits

Conventional commits are a specification that helps write semantic messages by following certain rules. These rules make it easy for us to know what and how to write our commits.

Git Conventional Example

When writing a commit following the conventional commits guide, it has the following structure.

type: scope: description or message
optional body
optional footer

The type expresses the intention, and the scope indicates the affected area. For example:

fix: (icon-library) 
Change the input prop of the state icon to match the identifier.
Refs: #jira-ticket-number or pbi

More options are:

  • feat: new feature

  • fix: when fixing a bug.

  • docs: documentation, edit markdown etc.

  • chore: changes don't affect code or source code.

You have additional options such as test, revert, build, ci, styles, or BREAKING CHANGE. For more options, please refer to the official documentation.

How I Write Conventional Commits?

I prefer to use an extension instead of writing every time or make it easy with a single click, integrating it into my IDE or terminal.

VSCode: https://marketplace.visualstudio.com/items?itemName=vivaxy.vscode-conventional-commits

WebStorm: https://plugins.jetbrains.com/plugin/13389-conventional-commit

Terminal: https://ttys3.github.io/git-cz/

I'm a huge fan of GitKraken, but sadly they don't have support for conventional commits yet. However, you can help me by voting for the conventional commits initiative.

๐Ÿ™๐Ÿฝ Please Sign and Vote https://feedback.gitkraken.com/suggestions/198202/conventional-commits-support

Recap

We learned how to use Conventional Commits to provide a standardized approach to writing commit messages, making it easier for team members to understand code changes.

I hope to use it with an extension in your IDE or Terminal for future projects.

ย