Git commit message writing tips

From Logic Wiki
Revision as of 08:15, 28 October 2021 by AliIybar (Talk | contribs) (Created page with "Category:git File:Commit.png == The 10 commonly accepted rules on how to write a git commit message are: == # A commit message is comprised of a '''subject ( i.e sum...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Commit.png

The 10 commonly accepted rules on how to write a git commit message are:

  1. A commit message is comprised of a subject ( i.e summary), body, and footer, with both the body and footer being optional.
  2. Limit the subject line to 50 characters.
    1. The subject is a single line that best sums up the changes made in the commit.
    2. 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.
  3. Capitalise the first latter of the subject line.
  4. Don’t put a period ( . ) at the end of the subject line.
  5. Put a blank line between the subject line and the body & also between body and footer.
    1. 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.
  6. Wrap the commit body at 72 characters.

The body text is used to provide more details regarding the changes made in the commit.

  1. Write the commit body in bullets (OPTIONAL).

Commit body looks clean when written in terms of bullets.

  1. Use imperative mo0d
    1. Example: Say Add instead of Added
    2. Say Fix instead of Fixed, Fixes → Use present tense imperative for the subject line and present tense for body text
    3. The present imperative should be used for the subject line of commit messages. This is what has been standardized by git itself.
  2. Describe what and why, but not how.
    1. Maybe Mention Which component is changed.
    2. Just keep your mind on the purpose, not the implementation.
    3. 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.
  3. Footer contains issue no. and ticket if needed (OPTIONAL).
    1. 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

Gitmoji

https://gitmoji.dev/