Semantic Git Commit messages which everyone should follow! ๐Ÿ“

Semantic Git Commit messages which everyone should follow! ๐Ÿ“

ยท

2 min read

Semantic Git Commits

Semantic Git Commits are commit messages with human and machine readable meaning which follow particular conventions.

It means that these are the guidelines that should be followed while writing commit messages, so that:

  1. The commit messages are semantic - because these are categorized into meaningful types, indicating the essence of the commit.
  2. The commit messages are conventional - because these are formatted by consistent structure and well-known types.

The commit message should be structured as follows:

<type>[optional scope]: <subject>
[optional body]
[optional footer(s)]

A commit message consists of three parts- header, body and footer

The header is the most important line which describes the purpose of the commit.

It consists of three parts:

  1. type - represents the kind of change
  2. scope - represents the context of change
  3. subject - represents a concise description of the change

semantic.png

Standard "type" messages

These are a few standard type messages that are commonly followed:

  1. build : Build related changes such as updating build tasks, package manager configs, etc (formerly known as chore)
  2. ci : Development related changes such as continuous integration and deployment system - involving scripts, configurations or tools.
  3. docs : Documentation related changes.
  4. feat : Production related changes such as adding a new feature.
  5. fix : Production related changes such as bug fixes.
  6. pref : Production related changes such as performance improvements.
  7. refactor : Development related changes that neither adds a feature nor fixes a bug - such as removing redundant code, simplifying the code, renaming variables, etc.
  8. style : Development related changes that changes the styling of codebase.
  9. test : Development related changes such as refactoring existing tests or adding new tests.

Body

The body contains the description which tells us the motivation behind the change.

The footer contains the consequences that tell us the outcome of the change, such as announcing a breaking change, linking closed issues, mentioning contributors, etc.

ย