Creating Good Commit MessagesJan 24, 2022
Partilha este artigo:
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
- 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
- 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.
- 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 pagesFreshchat was recently removed in f47ecb0.The community team requested that we restore it on 3 pages:- /premium-domains-nft-sale- /cart- /checkout[#179377974]