A Brief Introduction to Conventional Commits

A Brief Introduction to Conventional Commits

Introduction

Every software development team should adhere precisely to the Conventional Commits specification to maintain a structured commit history in Git. Conventional Commits offers a simple set of guidelines for producing an explicit commit history, which facilitates the development of automated tools on top of it. 3 minutes of reading the specifications might help you make your commit messages better.

According to the homepage Conventional Commits means:

A specification for adding human and machine readable meaning to commit messages. The Conventional Commits specification is inspired by, and based heavily on, the Angular Commit Guidelines.

via GIPHY

Commit Message Structure

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

A very brief overview of the comment's purpose or content can be found in the <description> field. The modification can be introduced in the <description> field's title, and then more information about the change can be included in the <body> field.

Conventional Commits Type

Some of the most useful types are:

SyntaxDescriptionExample
featto add a new featurefeat: add header component
fixbug fixesfix: undefined issue
docsfor documentationdocs: updated readme.md file
stylechanges to the code that do not affect the meaning ((white­-space, format­ting, missing semi-c­olons etc.)style: improve main page style
refactora code change/cleanup that neither fixes a bug nor adds a featurerefactor: refactor x function
perfany code change that improves performanceperf: code-splitting for best performance
testautomated teststest: add missing test for X controller
buildchanges to affect the build system or external depend­encies (yarn, npm, serverless etc.)build: switch from npm to yarn
chorechanges related to code cleanupchore: remove unused components
revertto revert an accidental commitrevert: revert commit x
cichanges to CI configuration files and scriptsci: add unit testing using Jest in the ci steps
bumpmanaging the dependency versionsbump: migrate from vue 2 to vue 3

BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.

Conclusion

Conventional Commits can aid with CI/CD pipelines by integrating nicely with automated tools like husky and reviewdog in addition to keeping a cleaner git commit history. So stop waiting and begin utilizing it right away! 😃

via GIPHY

Resources

Conventional Commits homepage