Creating Good Commit Messages

Jan 24, 2022

Compartir este artículo:

Having a well-crafted commit message will save you from using many tools to inspect changes in a project. Proper commit messages will make it easy to understand why a change was made at a particular time. This post explains the approach we recommend using in commit messages.

Format of the Commit Message

The format of a commit message can be separated in three distinct parts separated by a blank line: the message summary, body, and footer. The summary is required but the other two sections are optional. When a change is very simple, a message summary is usually enough.

Message Summary
<blank line>
Message Body
<blank line>
Message Footer

Message Summary

  • Give a summary of your change in around 50 characters or less
  • Use the imperative mood in the subject line
# Bad
❯ I added a README.md to the project
# Good
❯ Add README.md to the project
  • No dot at the end
  • Capitalize first letter

Message Body

  • Wrap the body at around 72 characters. You have to do it manually (or configure your editor to do it for you) because Git doesn't do it for you. If you don't then your paragraphs will flow off the edge of the screen when using something like `git log`.
  • Leave out the details about how a change was made. When a commit is explained, focus on the why and what. Details about how a change was made can be explored simply by taking a look at the code. If the code being committed necessitates extra explanation, then this is best handled with source comments.
  • Bullet points and new lines are okay to use.

Message Footer

  • Mention breaking changes if applicable
  • Add a reference to the issue or other issues if applicable

Sample of a Good Commit Message

Restore Freshchat on a few pages
Freshchat was recently removed in f47ecb0.
The community team requested that we restore it on 3 pages:
- /premium-domains-nft-sale
- /cart
- /checkout
[#179377974]

Recommended Readings

Author

Hassan Ali

Puestos de trabajo actuales

  • Data Engineer, Analytics - Remote

    Tiempo completo · Remote, US/Canada

  • Director of Engineering, Mobile - Remote

    Tiempo completo · Remote, US/Canada

  • Director of Platforms - Remote

    Tiempo completo · Remote, US/Canada

  • General Opportunities - Engineering

    Tiempo completo · Remote, Global

  • Head of Regional Marketing, APAC

    Tiempo completo · Remote, Asia-Pacific

  • Middle iOS Developer

    Tiempo completo · Remote, US/Canada

  • Senior Android Developer

    Tiempo completo · Remote, US/Canada

  • Senior Android Developer

    Tiempo completo · Remote, Europe

  • Senior Blockchain Developer - Remote

    Tiempo completo · Remote, Europe

  • Senior Fullstack Engineer, Ecommerce - Remote

    Tiempo completo · Remote, US/Canada

  • Senior Fullstack Engineer, Login - Remote

    Tiempo completo · Remote, US/Canada

  • Site Reliability Engineer - Remote

    Tiempo completo · Remote, US/Canada

Únete a nuestras redes sociales

Centro de Ayuda