DEV Community

Cover image for How To Improve Your Git Commit Messages Using Conventional Commits
Dany Paredes
Dany Paredes

Posted on

How To Improve Your Git Commit Messages Using Conventional Commits

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


Enter fullscreen mode Exit fullscreen mode

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


Enter fullscreen mode Exit fullscreen mode

More options are:

  • feat: new feature

  • fix: when fix 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

push

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

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

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.

Top comments (1)

Collapse
 
overflow profile image
overFlow

awesome!!!
It has left me feeling lifted a little.
And this is also helpful thank you .