Skip to main content

Conventional Commits

Conventional commits](https://www.conventionalcommits.org/es/) are a way of writing commit messages that follow a predefined structure. This structure makes it easier for both humans and automated tools to understand the commit history.

Advantages​

  1. Clarity and organization: Standardized commit messages are easier to read and understand, making it easier to track changes made to the project.
  2. Effective collaboration: Conventional commits facilitate communication between team members, since everyone understands what each type of commit means.
  3. **Standardized commit messages can be used by automated tools to generate changelogs, determine version changes and run continuous integration scripts.
  4. **Conventional commits facilitate long-term project maintenance, as the commit history is more organized and understandable.
  5. Universal adoption: This standard is widely adopted by the development community, facilitating collaboration with other teams and integration with third-party tools.

Structure​

A conventional commit consists of three main parts:

Type​

The commit rate indicates the exchange rate that has been made. The most common types are:

  • feat: Introduces a new feature or functionality.
  • fix: Corrects an error.
  • chore: Maintenance tasks that do not affect the source code (ex. update dependencies).
  • docs: Documentation changes.
  • style: Formatting changes in the code (ex. indentations, blank spaces).
  • **Reorganization of the code without changing its functionality.
  • test: Adds or modifies tests.
  • **Changes in the compilation system or dependencies.
  • ci: Changes in the continuous integration configuration.

Scope (optional)​

The scope indicates the part of the code that has been affected by the change. This is an optional field, but can be useful to quickly identify relevant changes.

Description​

The description is a short sentence summarizing the change made. It should be clear and concise, and should provide enough information so that someone can understand the change without having to read the code.

Example of a Conventional Commit:

feat: Implement new login function

This commit introduces a new login feature in the project.

Additional commit types:

BREAKING CHANGE: Indicates a change that breaks backward compatibility. It should be included in the footer of the commit message.

Tools​

There are several tools that help you work with Conventional Commits in your project.

Validation of commit messages​

  • Commitlint Allows you to configure rules to validate that commit messages follow the convention.
  • Husky Integrate Commitlint into your Git workflow, preventing commits with invalid messages.

Generation of commit messages​

Other Tools​

The best tool for you will depend on the specific needs of your project. Some factors to consider are:

  • Team Size: If you work in a large team, it is important to have a tool to help ensure consistency in commit messages.
  • Workflow: If you use a continuous integration tool, it is important to find a tool that integrates with it.
  • Personal preferences: Some people prefer to write commit messages manually, while others prefer to use a tool to help them.