About Commit Message

Meng Lin, in 01 February 2019
There are a million ways to write your commit message, and there are a million ways to mess it up, and ths xkcd comic sums it up very nicely.
Git commits by xkcd
Git commits by xkcd

Even though there’s no correct answer to writing a commit message, there are principles to follow to make the commit messages more clear and readable, and people will really appreciate the effort put into making it nicer when tracing a bug or trouble shooting.

A good commit message

A good commit message should look like this:

JIRA-101 feat: add a new icon to home page

- add icon
- update CSS styling to accommodate the new icon

Co-authored-by: Bob <bob@example.com>

The commit message can be broken down to the following parts:

<ticket-number> <semantic-tag>: <commit-message>

- <description1>
- <description2>

Co-authored-by: <participant1>
Co-authored-by: <participant2>

If this makes sense straight away, then you are good to go. But if you want more theory backing, carry on reading and I will do my best to explain.

Small commits

You may be wondering why including semantic tag is a good idea. In order to understand why, let’s establish that small commits are more welcomed for the following reasons:

Semantic tag

On top of small commits, semantic tag is a crutch to help you identify what can go in as one commit. You can use the following principles to decide what semantic tag is the most appropriate:

Commit message

There are also a few guidelines to follow when writing a commit message body:

These principles can optimise how commits look in GitHub, and the more you use it, you will find it a massive help to team collaboration.

Happy days!