The Seven Golden Rules of a git commit
23-02-2025
Tags: Computer Science, Community, Practical Tip, List, Tech and Internet environment, Web Culture and Etiquette, Open Source
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why (instead of how)
-
It is a good idea to make good commit messages for many reasons. One: your future employers will go through your commits and see if you have good practice. Two: it signals you're good at collaborating.
-
Strive for atomic commits. ( hey i've heard this one before)
-
you can use
git log --oneline to see only the subject line: or git shortlog which groups by user, showing just the subject line.
-
CLI command
git commit -m won't be good to write the body of a commit with. Use a text editor.
-
Do not use past / indicative! Use imperative. It should be able to complete the sentence "If applied, this commit will _______".
For example, "If applied, this commit will *update README.md / Release version 1.0.0 / merge pull request"
-
The body, on the other hand, can be indicative-moded.
Example of suggested Git Commit in the Curl repository
[area]: [short line describing the main effect]
[separate the above single line from the rest with an empty line]
[full description, no wider than 72 columns that describes as much as possible as to why this change is made, and possibly what things it fixes and everything else that is related]
[Bug: link to source of the report or more related discussion]
[Reported-by: John Doe—credit the reporter]
[whatever-else-by: credit all helpers, finders, doers]
Related:
The Seven Golden Rules of a git commit
|