How to Write Useful Git Commit Messages

Fixed Something.

Ion Utale


Git commit messages are like tiny love letters to your future self. They should be clear, concise, and informative. They should tell you what you changed, why you changed it, and how to revert the change if something goes wrong.

But writing useful commit messages is not always easy. It can be tempting to just write “Fixed something” or “Made some changes.” But these messages are useless. They don’t tell you anything about what you actually changed or why.

So how do you write useful commit messages? Here are a few tips:

  1. Start with a clear and concise subject line. The subject line should summarize the main change that you made in the commit. It should be no more than 50 characters long.
  2. Provide a detailed description of the change in the body of the commit message. The body of the commit message should explain what you changed, why you changed it, and how it works. It should be as specific as possible.
  3. Use the imperative mood. The imperative mood is a verb tense that tells the reader what to do. For example, “Add support for new database” instead of “Added support for new database.”
  4. Use past tense. Commit messages should be written in the past tense because they describe changes that have already been made.
  5. Use present tense. Commit messages should be written in the present tense when describing the current state of the code.

Here are a few bad examples of commit messages, and why they are bad:

⚠️ Bad:

  • Fixed something.
  • Made some changes.
  • Added a new feature.
  • Updated the code.
  • Refactored the code.

What do you call a commit message that says “Fixed something”?

A mystery.

Here are a few good examples:

👍 Good:

  • Fixed a bug in the user authentication system.
  • Added support for the new database.