Git Etiquette: Meaningful Messages & Linear Logs!

Why Elegant Git Logs Matter?

I will show You few commit messages & logs from two different projects. Based only on those messages/logs, You need to decide which project is the best.

Project 1:





Project 2:





I hope that explains why We need  to maintain elegant git logs.

How To Maintain Elegant Logs?


First let's see how to write good commit messages. There are several blog  posts  & guides about this. Here is the summary of all those taken from this article.

1. Separate subject from body with a blank line
2. Limit the subject line to 50 characters
3. Capitalize the subject line
4. Do not end the subject line with a period
5. Use the imperative mood in the subject line
6. Wrap the body at 72 characters
7. Use the body to explain what and why vs. how

If You are doing something hacky, writing a little message in commit on why you did that will help other developers to understand that a lot better. Even if You don't follow all rules, some of them will help you in writing great commit message next time. If You are mainainter of a project, ask Your team members to write meaningful messages.

The next that need to be taken care is commits. If a team member or someone else has submitted a pull request, once you merge the commit, just rebase it to remove unnecessary merge commits from log. Also make sure to squash  redundant commits and You have almost a linear log.

A side benefit of this is, You can see recent commit there instead of merge commit, if your project is hosted on github.


The two minutes You spent on writing a meaningful message or maintaining linear log will
will help You a  lot few months down the line & will save countless hours and sleepless nights for future contributors.


Read more articles about Technology!