DEV Community

Cover image for Simplified: 8 Guidelines for Commit Message
Tito
Tito

Posted on

Simplified: 8 Guidelines for Commit Message

Introduction

Writing quality commit messages is what distinguishes the level of professionalism of an engineering team. As Quality commit messages ease collaboration and code maintenance.
Have you been writing quality commit messages?
Check and review some if not all your commit message by running this command on your git bash console or Terminal

 git log
Enter fullscreen mode Exit fullscreen mode

Are you proud of what you have been writing?
Now take time and read this article to understand tips for writing professional git commit messages that tech novices can comfortably understand and derive a report out of it.
This article, assumes you have a basic for git workflow. If this is your first encounter kindly read

Guidelines for Commit message

  1. Thou shall not write commit messages in the past tense One of the most emphasized rules for writing commit message is to ensure both the body and subject are not written in the past tense. Instead, use the present tense Example
git commit -m 'Fixed button colour'
Enter fullscreen mode Exit fullscreen mode

Instead

git commit -m 'Fix: Change of button colour'
Enter fullscreen mode Exit fullscreen mode

2. Thou shall not write short/unclear messages with a maximum of 50 characters

For the benefit of the maintainer, it is advised not to write a movie script with characters. Instead, write a clear commit subject and body. With a maximum of 50 characters.

3. Thou shall refer to bug ID

In big projects, there are systematic reporting channels where every bug has an id. The Id is referred to the issue registered on GitHub. Therefore including this id would make it easy to track the issue.
Example

git commit -m "#5:improve lazy loading"
Enter fullscreen mode Exit fullscreen mode

4. Thou shall specify the type of commit

Specifying the type of commit makes it
feat: The new feature you're adding to a particular application
fix: A bug fix
style: Feature and updates related to styling
refactor: Refactoring a specific section of the code base
test: Everything related to testing
docs: Everything related to documentation
chore: Regular code maintenance. Example

git commit -m "feat:A bug fix"
Enter fullscreen mode Exit fullscreen mode

5. Thou shall separate the subject and body by one line

Writing a commit message with both body and subject will provide excellent documentation to other team members.
For those in a Debian environment, just type

 git commit -a
Enter fullscreen mode Exit fullscreen mode

and Vim editor will be prompted. Write the Subject and body into different lines, save and push to the remote repository.

6. Thou shall not include unnecessary punctuation in the message

Avoid adding unnecessary punctuation such as question marks, apostrophes and semi-colon. Don't create suspense in your colleague's mind. Just be clear

7. Thou shall follow rules set by the team

Rules are there to be broken. However, this is not the case in the software engineering world. Instead, rules are set to harmonize the team during the development and maintenance period. Respect them at all costs, as it is expensive to break them.

8. Thou shall start the message with an impressive verb e.g. as “Add”, “Fix”, “Update” “Delete”

Bonus Tip

You can also use emojis to represent commit types. In visual Code, install the Gitmoji extension

Top comments (0)