DEV Community

Cover image for Conventional Commits
Alvaro Torres Carrasco
Alvaro Torres Carrasco

Posted on • Updated on

Conventional Commits

Hello 🙋‍♂️, today I´m going to write about Conventional Commits (as you can see in the title). I've always wondered if there was a standardization with commits. I think this standardization is necessary and it can make our life easier. I asked a colleague if this exists, and it's the topic I'm going to talk to you about.

Git is a very powerful tool that most of us have installed on their machines. The worst part of using git is the no standardization with commits. Many people don´t follow any rules and the commit log, when you have to work with a team, has many possibilities to be chaotic.

Conventional Commits is a specification for adding human and machine-readable meaning to commit messages. This is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history, which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.

Commits should have the following structure:

<type>[optional scope]: <description>

[optional body]

[optional footer]

Types of commit:

  • feat: Add a new feature to the codebase (MINOR in semantic versioning).
  • fix: Fix a bug (equivalent to a PATCH in Semantic Versioning).
  • docs: Documentation changes.
  • style: Code style change (semicolon, indentation...).
  • refactor: Refactor code without changing public API.
  • perf: Update code performances.
  • test: Add test to an existing feature.
  • chore: Update something without impacting the user (ex: bump a dependency in package.json).

Some examples:

Commit with no body:

feat: allow provided config object to extend other configs

docs: correct spelling of CHANGELOG

Commit message with scope:

feat(lang): add spanish language

Commit message for a fix using an (optional) issue number:

fix: correct minor typos in code

see the issue for details on the typos fixed

closes issue #12



Commits are more descriptives and it's easier to understand them. It became also easier to contribute.


Automatically generating CHANGELOGs.

Revert changes

If you have one action per commit, it´s easier to revert a change or a git conflict

Improve your Git skills

Not all repositories have a squash and merge option, you sometimes have to do this operation by yourself. It's important to know what is going on under the machine operations!!

Follow me on Twitter if you want to know about my future articles, projects or whatever

Top comments (0)