commit_message_convention.md

January 5, 2022 ยท View on GitHub

Git Commit Message Convention Back

An extension based on kazupon/git-commit-message-convention, which is actually an extension edition from angular style. This document mainly aims to give out a convention of git commit messages of mine and help reuse by others. Why is a convention required? Because it should result in a more elegant history, which the future contributors can trace back one day.

All Commit Messages MUST be formatted like this:

<Type>[(<Scope>)]: <Subject> [#<Issue>] [!<MR/PR>]
[<BLANK LINE>]
[<Message Body>]
  • Type: mainly used to describe what kind of your message is around this commit.
TypeDescription
featurefor new feature implementing commits
fixfor bug fix commits
improvementfor backwards-compatible enhancement commits
breakingfor backwards-incompatible enhancement commits
refactorfor refactoring commits
docs/docfor documentation commits
examplesfor examples commits
testfor testing commits
lintfor linting commits
typofor typo fixing
dependencyfor dependencies commits like upgrading or eliminating
buildfor packaging or bundling commits
releasefor publishing commits (tag here in most cases)
wipfor work in progress commits (deprecated to avoid conflicts)
revertfor reverting commits
chorefor any other commits without specified type
  • Scope: mainly used to describe which parts you have modified, similar to namespaces. For instance, login/Confirmbox can be a scope standing for the ConfirmBox component in the login module.
  • Subject: a laconic subject to describe what your code has done.
    • DO NOT capitalize the first letter.
    • DO NOT add trailing dot (.) at the end.
  • Issue: identification of issues related to commits, like GitHub Issue ID or JIRA Issue ID.
  • MR/PR: identification of merge requests, or pull requests, related to commits.
  • Message Body: a more detailed description after a subject.

In addition, we can use some helpful tools to lint our commit messages before committing or even integrate with CI to handle unconventional commit messages. husky is one of my choices for registering git hooks so that we can lint messages before committing. In addition, commitlint is one of the best tools for checking messages with the format above.