Write Commit Messages Like a Pro: The Power of Conventional Commits

In my journey to becoming a better developer, I recently learned of a practice called “Conventional Commits.” This came to my attention after noticing how clean and easy to understand a new teammate’s commit messages were. Intrigued by their approach, I decided to give this convention a try.

It turns out, this decision has significantly improved my commit messages, making my development process more efficient and organized. Conventional Commits transformed how I write commit messages, streamlined my workflow, and made collaboration within my team easy.

The format is simple and consists of three main parts: a type, an optional scope, and a description.

Defining Conventional Commits

Conventional commits is a commit message convention that provides a set of rules for crafting commit messages. The specification is language-agnostic. That means you can apply it to any version control system that supports commit messages, such as Git. The goal of conventional commits is to standardize the format of commit messages. In turn, that makes it easier to understand the changes introduced in each commit.

Format

The format of a Conventional Commit message is straightforward. It consists of three main parts: a type, an optional scope, and a description.

<type>(<scope>): <description>

The Type

The type indicates the nature of the commit and can be one of the following values:

  • feat: A new feature or functionality.
  • fix: A bug fix.
  • docs: Documentation-related changes.
  • style: Changes to code style (e.g., formatting, indentation).
  • refactor: Code refactoring without changing its functionality.
  • test: Adding or modifying tests.
  • chore: Miscellaneous changes unrelated to code or tests (e.g., build tasks, dependency updates).

Scope (optional)

You can use the optional scope to provide additional context. It represents the specific module, component, or section of the codebase that the commit affects.

The Description

The description briefly explains the changes made in the commit. It should be clear and concise. That’s because the goal is to help other developers grasp the purpose of the commit.

Here’s an example:

feat(user): add user login functionality

The Power of Conventional Commits

Using a standard format of commit messages made it easier to understand changes made in our codebase. It has also facilitated more seamless collaboration with my teammates. If you are a developer looking to level up your commit message game, I highly recommend trying this!

Conversation

Join the conversation

Your email address will not be published. Required fields are marked *