DEV Community

Cover image for How To Write Better Git Commits
Mithil Poojary
Mithil Poojary

Posted on


How To Write Better Git Commits

Git plays a very important role in software development. It allows for collaboration across the globe. In such an ecosystem, git commits must show what the other developer's thought process was while working. Maybe that other developer is your self from 3 months back.

  1. The title must start with a capital letter unless it is an identifier.
  2. The body and the title must be separated by 2 blank lines.
  3. The title should not end with a period.
  4. Each line in the body shouldn't exceed 75 characters.
  5. Use the imperative form of verbs (Add not Added, Remove not Removed).
  6. The title shouldn't exceed 72 characters.
  7. The commit's body must explain the entire thought process behind the changes or further details.
  8. Your git commit must have a title that briefly sums up the changes made to the codebase.

You could visit any successful open source project and view their git commits.
For example, this commit is a good example of a well-written commit.

I would like to quote what Atom says in their contributing guidelines.

These are mostly guidelines, not rules. Use your best judgment.
Enter fullscreen mode Exit fullscreen mode

This is a summary of these resources:
Gnome guidelines
Atom guidelines
I highly encourage to read these. 😄

| Photo by Yancy Min on Unsplash

Top comments (0)