Conventional Commits Cheat Sheet

Conventional Commits is a specification for writing standardized commit messages. These messages follow a defined convention, making it easier to understand the history of a project and automate the release process. Here’s a cheat sheet for Conventional Commits:

Commit Message Format

Structure:

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

[optional body]

[optional footer]

Example:

feat(user-auth): add password reset functionality

Implements password reset functionality for user authentication.

Closes #123

Commit Types

  • feat: A new feature for the user or client.
  • fix: A bug fix for the user or client.
  • docs: Documentation changes.
  • style: Code style changes (formatting, missing semi-colons, etc.).
  • refactor: Code refactoring that does not change its external behavior.
  • test: Adding or modifying tests.
  • chore: Routine tasks, maintenance, or tooling changes.
  • build: Changes that affect the build system or external dependencies.
  • ci: Changes to the Continuous Integration (CI) configuration files and scripts.

Commit Scopes

  • Scopes provide additional context to the commit. Examples include user-auth, payments, config, etc.

Commit Descriptions

  • Begin with a lowercase verb.
  • Be concise and to the point.
  • Do not end with a period.

Commit Body

  • Provide more details when necessary.
  • Use the body to explain the motivation and reasoning behind the changes.

Commit Footers

  • Closes #<issue_number>: Indicate that the commit closes an issue.
  • Breaking Changes: Describe any breaking changes introduced by the commit.

Versioning and Releases

  • Follow Semantic Versioning (SemVer).
  • Breaking Change: Increment the major version.
  • New Feature: Increment the minor version.
  • Bug Fix: Increment the patch version.

Examples

New Feature:

feat(search): add fuzzy search functionality

Adds fuzzy search capability for better user experience.

Closes #42

Bug Fix:

fix(validation): resolve issue with email validation

Fixes a bug where the email validation was not working properly.

Closes #87

Commitizen and Commitlint

  • Commitizen: A tool for writing standardized commit messages.
  • Commitlint: A tool for linting commit messages against Conventional Commits.

Commit Message Convention

  • Enforce the Conventional Commits convention across the project.

By adhering to the Conventional Commits specification, you can streamline your Git history, automate the release process, and improve collaboration within your development team.