This is the second part of my last blog post and in this one let’s talk about commit messages. Commit messages are important means of communication between team members and for the lifecycle of the teams and projects since they include the context in which they were created. By inspecting the project history we can find out why some decisions were made when they were made.

I started to write good commit messages since I started contributing to Sustainable Educational Foundation — SEF in late 2019. For those who don’t know about SEF please make sure to visit our site to know more details. In a nutshell, At SEF, we have something in store for everyone especially you are a student, expert, or a volunteer. After starting contributing to SEF I realised the importance of a good commit message and today I’m going to share those qualities with you.

Without talking too much let’s get to key points that make a commit message great.

Capitalize the first letter of the commit message.

Begin all subject lines with a capital letter.

ex:

  • Correct
  • Update the example page
  • Incorrect
  • update the example page

Limit the subject line to 50 characters.

This length ensures that they are readable. GitHub’s UI is fully aware of these conventions. It will warn you if you go past the 50 character limit and will truncate any subject line longer than 72 characters with an ellipsis.

ex:

  • Correct
  • Bug fixed in the example page
  • Incorrect
  • Hi, everyone, I have good news for you. I just fixed the bug in the example page. blah blah blah

Image for post

Image for post

Do not end the subject line with a period

Trailing punctuation is unnecessary in subject lines. Also when you’re trying to keep them to 50 chars or less, Space is more important.

ex:

  • Correct
  • Remove unnecessary imports
  • Incorrect
  • Remove unnecessary imports.

Try to communicate what the change does without having to look at the source code

It is useful in many scenarios (e.g. multiple commits, several changes, and refactors) to help reviewers understand what the committer was thinking.

ex:

  • Correct
  • Add use method to Credit model
  • Incorrect
  • Add use method

Separate subject from the body with a blank line

If the commit message has both subject and body. It is good to separate those two with a blank line. It is useful when checking the git log.

ex:

  • Correct
  • Update the github link

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit varius varius. Nunc vulputate ac urna ac rutrum. Etiam tincidunt et nunc eget pretium. Morbi sed tempus augue. Duis sollicitudin lectus ac aliquet varius.

#gitlab #git #github #2020 #hacktoberfest

What Makes a Commit Message a Good Commit Message?
1.85 GEEK