Skip to content

Instantly share code, notes, and snippets.

@d-simon
Last active January 31, 2021 10:43
Show Gist options
  • Save d-simon/d6ff981c2843077c2847 to your computer and use it in GitHub Desktop.
Save d-simon/d6ff981c2843077c2847 to your computer and use it in GitHub Desktop.
Commit Guidelines

Commit Message Guidelines

This is a proposal for structuring commit messages. It is a set of guidelines evolved from a need to scan, review and navigate commits quickly. They are ment to bring clarity to the commit history while retaining a lot of flexibility.

Structure

[Action] Scope: Summary

(Involved Commits)

Detailed Body Text (if necessary)
  • The scope can be many things. File(s), Components, Sub-Systems. In fact any conceptual unit or scope that the commit applies to.

  • The summary as well as body text lines should be kept below 70–80 characters by manually wrapping the lines. (Github "elipsizes" at 70 chararacters. Often mentioned are 70 or 72)

Alternate Title Structures

Possible (alternate) structures for the commit title line include:

[Action] Scope: Summary

Action | Scope: Summary

action(Scope): Summary      // the angular.js team uses this

ACTION - Scope: Summary

ACT: Scope | Summary

At a certain scale it might make more sense to actually communicate the scope before the action.

Scope: Action | Summary

##Action Keywords

This is a list of proposed action keywords. It is in no way a definitive list. Rather, it reflects my personal findings of required keywords I have encountered. Others have been left away for their infrequent use i.e. Init or their ambiguity i.e. Cleanup. A keyword length of 4-6 letters is recommended where possible.

  • Update
  • Feature
  • Refactor
  • Fix
  • Chore
  • Merge
  • Release
  • Docs
  • Revert
  • WIP
  • Test

Update

Update: A generic update that involves changes and does not fit any other category.

Feat

Feature: A commit that introduces a feature. This can also be a merge of a feature branch.

Refact

Refactor: Refactoring changes that do not change functionality per se.

Fix

Fix: Code fixes and bug fixes

Chore

Chore – Replaces Style | Format: Includes Cleanup, whitespace, formatting, old dependencies etc. Should not change functionality.

Merge

Merge: Branch merges. Includes a list of merged commits. For a feature branch merges Feat/Fix or others might be more apropriate.

Release

Release: Version Releases

Docs

Docs: Changes to the documentation.

Revert

Revert: Revert a commit/change(s).

WIP

WIP: Work in Progress

Test

Test: Tests

Ticket/Issue References

References to tickets and issues (e.g from JIRA) most probably should not go into the title message. They do not convey relevant information to what the commit actually does. Most ticketing or project management systems detect ticket numbers in the message regardless of it's position. (Checkout smart commits for JIRA.)

##Chaining Action Keywords Chaining has been proposed several times. It might help on merges for example:

[Merge][Feature] Header-Navigation

[Merge/Feature] Header-Navigation

[Merge|Feature] Header-Navigation

Merge|Feature – Header-Navigation

[Feature][Merge] Header-Navigation

Samples

[Feature] Header: Add header element

[Update] header: Move main-nav a bit to the bottom
[Update] service-nav: Add structure/module file
[Fix] Reference: Change reference from all.scss to main.scss in index.html.erb.
[Refactor] Structure: Move styles for main-nav / header into their own files
[Update] Header: Initial strucutre
[Update] Grid: Adjust breakpoints / Import container size configuration

Conflicts:
source/assets/css/main.sass
source/index.html.erb

...

[Fix] serviceBus: Add missing check for argument of complete() method

This resolves issue#2756 where some components were receiving errors
because the complete method did not check for it's arguments and
optimistically proceeded with the callback execution.

The solution was to add an integrity check for thepassed arguments to
the complete() method.

Other Guidelines

Capitalized, short (50 chars or less) summary

More detailed explanatory text, if necessary.  Wrap it to about 72
characters or so.  In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body.  The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.

Write your commit message in the imperative: "Fix bug" and not "Fixed bug"
or "Fixes bug."  This convention matches up with commit messages generated
by commands like git merge and git revert.

Further paragraphs come after blank lines.

- Bullet points are okay, too

- Typically a hyphen or asterisk is used for the bullet, followed by a
  single space, with blank lines in between, but conventions vary here

- Use a hanging indent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment