Ten Commandments of Git Commit Messages

Ten Commandments of Git Commit Messages

The Ten Commandments of Git Commit Messages is an attempt to unify Conventional Commits 1.0.0, the 7 rules of commit messages, and the format used by git itself, GitHub, and GitLab.

The Ten Commandments of Git Commit Messages is an attempt to unify Conventional Commits 1.0.0, the 7 rules of commit messages, and the format used by git itself, GitHub, and GitLab.

The commandments were mentioned in “sermon on the /mnt” as follows:

0. The git commit message shall not be empty

1. Separate header from body, and body from footer with a blank line

2. Limit the header to 72 characters

3. Thou shalt not use any case but sentence case for the subject

4. Thou shalt not end the subject with a period

5. Thou shalt not use but the imperative mood in the subject

6. Wrap the body and footer at 72 characters

7. Use the body to explain what and why vs. how

8. Use types for semantic versioning

9. Use footer to connect to issues and designate breaking changes

Introduction

The first section, §1. Commitlint, is about setting up a commit linter that validates commit messages according to the Commandments. The second section, §2. Commandments, is an explanation of the Commandments and the reason behind each.

§1. Commitlint

Image for post

Demonstration of Commitlint CLI

Using Node.js, one can enforce the Commandments using commitlint and commitlint-config-commandments:

npm i -D commitlint-config-commandments @commitlint/cli
echo "module.exports = {extends: ['commandments']};" \
  > commitlint.config.js

So far, only the Commandments 1, 2, 3, 4, and 6 are enforced by this preset config. After initializing the linter, linting can be done through piping via command line:

echo "Feat: Add dry run functionality" | commitlint

commit javascript git git-commit-messages

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Write git commit messages like a PRO with Conventional Commits

Good commit messages are important for maintaining any long-term project. If you follow this guide laid out in this video you can use conventional commits to...

How to Change a Git Commit Message

This guide explains how to change the message of the most recent or older Git commits.

Git Rebase Tutorial and Comparison with Git Merge

In this article, I will explain to you a few differences between git merge, git rebase, and the git interactive rebase.I will tell a bit about what pros...

GitHub for Data Scientists: Commit

Learn about components of a commit, making commits, git revert commit, git undo commit, checkout git etc. This article is part of a follow-along series on GitHub collaboration. In this article, we will try to understand commits in detail, like components of a commit, how to delete commit before and after push or how to reset it.

7 Best Practices in GIT for Your Code Quality

Git plays a significant role in software development. It allows developers to work on the same code base at the same time. Check out 7 best practices for Git.There is no doubt that Git plays a significant role in software development. It allows developers to work on the same code base at the same time. Still, developers struggle for code quality.