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:
- The commit messages are semantic - because these are categorized into meaningful types, indicating the essence of the commit.
- 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
Header
The header is the most important line which describes the purpose of the commit.
It consists of three parts:
- type - represents the kind of change
- scope - represents the context of change
- subject - represents a concise description of the change
Standard "type" messages
These are a few standard type
messages that are commonly followed:
build
: Build related changes such as updating build tasks, package manager configs, etc (formerly known aschore
)ci
: Development related changes such as continuous integration and deployment system - involving scripts, configurations or tools.docs
: Documentation related changes.feat
: Production related changes such as adding a new feature.fix
: Production related changes such as bug fixes.pref
: Production related changes such as performance improvements.refactor
: Development related changes that neither adds a feature nor fixes a bug - such as removing redundant code, simplifying the code, renaming variables, etc.style
: Development related changes that changes the styling of codebase.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.
Footer
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.