Sigma
Integral
πPi
E=mc²Einstein
Root
Infinity
f(x)Function
ΔDelta
ΩOhm
λLambda
Nabla
Writing Good Git Commit Messages for Collaboration
Back to Blog
Tips & TricksProgramming

Writing Good Git Commit Messages for Collaboration

February 12, 2024

This post was previously on Medium

Introduction

Git is an open-source version control tool used to manage changes in software projects, from small to large scale. Git is valued for its ability to enhance the speed and efficiency of version control and team collaboration.

Article

Each time you make a commit with Git, the project is saved in a specific state, allowing recovery to that state if any issues arise during updates or when adding changes on top of the previous state.

In every commit, the commit message is used to provide a brief description of the changes made. These messages are not only read by the commit owner but also by project team members. Therefore, writing clear and easy-to-understand commit messages for other team members is crucial.

Tips and tricks can help create more informative commit messages, aiding the team in understanding the changes made and preventing confusion in the future.

Project Image

Commit Message Structure

Although you are free to write commit messages as you like, here is a structure you can use with your team:

  • Type: The type of commit, for example, 'feat' to indicate a feature addition.
  • Short Description: A brief description of the commit with a maximum of 50 characters.
  • Body: A detailed explanation of the changes made, with no more than 80 characters per line.
  • Footer: The footer is used to include additional information such as closing an issue related to the commit.

Let's explain the structure above:

<commit-type>

The commit type indicates the kind of change you have made. The commit type can be:

  • feature: If you add a new feature to the project
  • fix: If you fix a known bug
  • refactor: If you refactor some parts of the code
  • test: Use this if you do anything related to testing
  • docs: Use this if you make any changes related to project documentation

<subject>

Write a short description of the commit with the following rules:

  • It should be a maximum of 50 characters; think of it as the title of your commit message.
  • Explain briefly but accurately.
  • Avoid unnecessary details.

<body>

Explain what changes you made and why you made them. Make sure the text does not exceed 80 characters. Your team members might not read lengthy texts, so keep it as concise as possible.

<footer>

Use the footer to explain new issues that arise after the changes are complete or provide comments, notifications, and warnings to other developers and testers.

For example, see below:

With a well-structured commit message, development teams can easily understand the changes made, the purpose of those changes, and any relevant additional information. This helps track the project's change history and facilitates collaboration among team members.

Comments