The Art of Writing Commits

A commit message basically says what the new code does to improve the project. By providing information about the development history, commit messages may help to understand for example how a bug you need to fix got there in the first place, or why a solution has be chosen over another.

Writing Commits

A commit must be written as if the first part of the sentence was If applied, this commit will .... For example, If applied, this commit will ...
Fix typo in introduction to user guide

The Conventional Commits specification

On top of commit messages, you may find in some projects, these following structural elements which help to communicate the intent:
docs: add setup guide section to README

Commitlint

Commitlint is the ESLint for commit messages. This tool checks if any text aligns with a predefined commit format. You can configure these formats to your needs or adopt pre-built-in conventions, such as conventional commits. Commitlint will then review and validate the messages right before committing changes, pushing, or using any other Git hook. If you want these commit message validations to run automatically on every Git commit command, you can use Husky, a tool that enables you to set up Git hooks quickly. Git hooks are preconfigured custom scripts that get executed before an action is performed in Git. By default, all the installed hooks are available in the .git/hooks directory with each filename being a hook name.

Resources