DEV Community

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

Posted on

4 1

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

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay