Git commit message writing tips
From Logic Wiki
The 10 commonly accepted rules on how to write a git commit message are:
- A commit message is comprised of a subject ( i.e summary), body, and footer, with both the body and footer being optional.
- Limit the subject line to 50 characters.
- The subject is a single line that best sums up the changes made in the commit.
- The act of summarising your commit is a good practice inherently in any version control system. It helps others (or a later you) find relevant commits more quickly.
- Capitalise the first latter of the subject line.
- Don’t put a period ( . ) at the end of the subject line.
- Put a blank line between the subject line and the body & also between body and footer.
- The blank line separating the summary from the body is critical (unless you omit the body entirely) the footer should also be separated from the body by an empty line.
- Wrap the commit body at 72 characters.
The body text is used to provide more details regarding the changes made in the commit.
- Write the commit body in bullets (OPTIONAL).
Commit body looks clean when written in terms of bullets.
- Use imperative mo0d
- Example: Say Add instead of Added
- Say Fix instead of Fixed, Fixes → Use present tense imperative for the subject line and present tense for body text
- The present imperative should be used for the subject line of commit messages. This is what has been standardized by git itself.
- Describe what and why, but not how.
- Maybe Mention Which component is changed.
- Just keep your mind on the purpose, not the implementation.
- Most of the modern bug-tracking and project management systems provide integration with the source control repository, but even if they don’t, you can still drop task/ticket numbers in the commit message – something like this. Of course – don’t rely on this being the only description of your message.
- Footer contains issue no. and ticket if needed (OPTIONAL).
- The footer text is found immediately below the body and is a place to reference issues related to the commit changes. Example Mention Issue no. in GitHub and If you are using JIRA to manage your project
