Conventional Commits are a standardized way to format commit messages. This practice makes it easier to understand the purpose of each commit, which is particularly helpful in larger projects or when working with others.

Benefits of Conventional Commits

  • Improved Readability: Commit messages are clear and easy to read.
  • Better Integration with Tools: Tools like GitHub, GitLab, and JIRA can better understand and utilize these messages.
  • Enhanced Collaboration: Team members can quickly understand the changes made by others.

Structure of a Conventional Commit

A conventional commit message follows a specific structure:

<type>(<scope>): <subject>
  • Type: Describes the type of change made to the code.
  • Scope: Optional. Describes the part of the project that was modified.
  • Subject: A concise summary of the change.

Common Commit Types

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (whitespace, formatting, etc.)
  • refactor: Refactoring code without changing its external behavior
  • test: Adding missing tests or correcting existing tests

Example

fix: Corrected typo in documentation

For more information, check out the official documentation.

图片

Here is an example of a commit message with a scope:

feat(user): Added login functionality

User