Skip to content

Instantly share code, notes, and snippets.

@rantoniuk
Last active September 2, 2019 13:46
Show Gist options
  • Save rantoniuk/d92ebec45711ca8d85d0049852f3014c to your computer and use it in GitHub Desktop.
Save rantoniuk/d92ebec45711ca8d85d0049852f3014c to your computer and use it in GitHub Desktop.
Git Commit Guidelines

Commit Message Guidelines

Example of a properly formed commit message:

JIRA-123 Short (72 chars or less) summary

More details about the change, including functional and/or technical
explanation. Wrap it to 72 characters. The blank line separating the
summary from the body is critical (unless you omit the body entirely).

Further paragraphs come after blank lines.

- Use bullet points if needed (preceded with hyphen or an asterisk, use 
MarkDown notation if possible)

Good examples

Fix color of the inbox message on the welcome screen
[#123] Add option to fix myself a coffee with a button

When a button is pressed on the mobile, the remote coffee machine 
will start coffee preparation process

Bad examples

Fixed proj-123
Fixed a bug in class Z.
- enabled the flag

Guidance for well-written commit messages:

  • separate subject from body with a blank line
  • use the imperative mood in the subject line, e.g. "Fix broken image" instead of "Fixed broken image"
  • do not end the subject line with a period
  • capitalize the subject line and each paragraph
  • wrap lines at 72 characters

Use the body to explain what and why you have done something. In most cases, you can leave out details about how a change has been made. Some questions that can aid in formulating explanation section:

  • The first commit line is the most important
  • Describe why a change is being made
  • How does it address the issue?
  • Do not assume the reviewer understands what the original problem was
  • Do not assume the code is self-evident/self-documenting
  • Read the commit message to see if it hints at improved code structure
  • Describe any limitations of the current code

Referencing ticket systems:

[#123] Refer to GitHub issue...
JIRA-123 Refer to Jira ticket with project identifier JIRA...

Fixes #123, JIRA-345 by introducting new class parameter.

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment