Skip to main content

Command Palette

Search for a command to run...

Understanding Conventional Commit Messages: A Simple Guide

Published
2 min read
Understanding Conventional Commit Messages: A Simple Guide
S
Teaching myself how to code

What are conventional commits?

Conventional commits is a lightweight convention for writing commit messages that follows a specific structure. This structure makes it easier for humans and machines to understand the intent of each commit. It’s especially useful for projects that use automated tools like version control systems and CI/CD pipelines.

The Basic Structure

A Conventional Commit message follows this format:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

  • Type: A keyword that indicates the nature of the change, such as feat for new features, fix for bug fixes, or chore for miscellaneous tasks.

  • Scope: An optional area of the project where the change was made (e.g., feat(api)).

  • Description: A concise summary of the change.

  • Body: Additional details about the change, if necessary.

  • Footers: Extra information, such as BREAKING CHANGE to indicate a major change.

Common Types

  • feat: A new feature

  • fix: A bug fix

  • refactor: A code change that neither adds a feature nor fixes a bug

  • perf: A performance improvement

  • test: Changes to tests

  • build: Changes to the build process

  • chore: Other changes (e.g., documentation, configuration)

Example

`feat(api): Add a new endpoint for retrieving user data

This new endpoint allows users to fetch their profile information using a GET request.`

Why Use Conventional Commits?

  • Improved Readability: Commit messages become more consistent and easier to understand.

  • Automated Tools: Many tools can leverage Conventional Commits to automate tasks like generating changelogs, determining version numbers, and triggering CI/CD pipelines.

  • Better Collaboration: It promotes a common understanding of commit types and makes it easier for contributors to work together effectively.

By adopting Conventional Commits, you can create a more organized and maintainable project history. It's a simple yet powerful practice that can benefit both individual developers and teams.

More from this blog

Sunil Kumar

14 posts

I'm Sunil, a full-stack dev learning networking and systems from the ground up. I write about what I learn as I go - protocols, projects, and things that took me way too long to understand. If you're learning too, you'll feel right at home.