Commit messages are important means of communication between team members and for the lifecycle of the teams and projects since they include the context on which they were created. By inspecting the project history we can find out why some decisions were made when they were made.
Let’s start a simple dare. Let’s post one important thing to consider when writing a commit message. Just one simple thing with an example after nominated by someone. You should nominate another one after posting yours.
Okay, I’m starting first with a super simple rule.
Capitalize the commit message.
Begin all subject lines with a capital letter.
ex: correct Update the example page
incorrect update the example page
I nominate @osusara. Keep in mind; just one simple thing with an example!
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
I nominate @Yohan . Keep in mind; just one simple thing with an example!
Use imperative mood
Write commit messages in the imperative mood. The imperative mood is a grammatical mood that forms a command or request. When we write commit messages in this mood it perfectly matches up with the auto-generated commit messages by git itself.
ex: correct Fix bug in the example page
incorrect Fixed bug in the example page Fixes bug in the example page
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.
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.
incorrect 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.
If the commit message has unnecessary punctuation marks, It’s better to remove them and just put the commit message with necessary parts. This will helps git to understand your commit message properly.
ex: correct Fix bug in the main page
incorrect Hi, all! I fixed the bug in the div with a class called "something" on the main page. I hope this will help...