Engineering Productivity — Better commit messages “git”

Dinesh C
Dinesh C
Dec 20, 2019 · 3 min read

What makes a good commit?

When a fellow developer reads through the commits,the commit message should convey the information very clearly and quickly. The following things can be used —

  1. Why the commit is needed? Is it for a Bug fix? Or a feature? Or just a refactor?
  2. What does the commit address and how?
  3. Can the commit be linked to external systems( JIRA, BugZilla or gitlab issues)

A better commit template :

← Start of commit template →

[Fix/Feature/Refactor] : [Type commit title here]

[Type commit explaination here]

Tracking ID : [Type Tracking ID Here]

← End of commit template →

Example :

How would this benifit large teams?

As the team size grows, individual developer characteristics would bring in inconsistancy in commit messages. Having a common commit template would make commit messages more consistent and predictable. Over a period of time, browsing through commit messages would become seemless and can be understood easily. Also, for the new joinees scanning the commit history would be really helpful.

How would the tracking id help?

  1. Linking commits to specific features tracked through tools like JIRA
  2. In the CI pipelines. Using the tracking id, CI systems could query tracking systems like JIRA, Gitlab, Bugzilla for statuses. Ex . Suppose there is a CI pipeline, that has to accept a merge request only if the status of feature is QA-Signed off, the tracking id would come in handy. While the merge request is raised, the CI pipeline that follows the merge request could parse through the commit messages. Post that it can extract thetracking id, query the tracking systems for the details. If status is QA-Signed off, only then accept the merge request, else reject the merge request right away.

Is there a way to automatically show the template on every commit?

Oh yes. Thats where git config comes in handy.

  1. Create a file containing the commit template and name it say .customtemplate.txt
  2. Edit git config

3. Try git commit now, and the template would appear right away and you can just edit the template to fit in your comments

Is there a way to enforce the commit message format?

Commit hooks like post commit hooks, pre commit hooks lets us run certain scripts on the the respective events. This would allow us to fail or accept the commit based on certain conditions.


Its very important to have a standard when scaling up teams. Especially in our case where we have more than 20 developers for our Android app development. Engineering process stanards become paramount — for Engineering Managers to review code and ask the right questions, this could be very helpful.

Title image credit : Photo by Yancy Min on Unsplash

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade