Skip to content

Instantly share code, notes, and snippets.

@rogerluan
Created December 3, 2021 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerluan/a05a41017cc43c734eb58e20daff8f5a to your computer and use it in GitHub Desktop.
Save rogerluan/a05a41017cc43c734eb58e20daff8f5a to your computer and use it in GitHub Desktop.
Commit Message Guidelines

Commit Message Guidelines

These guidelines are based off of this guide. Some of the key takeaways, plus some other opinionated guidelines:

  1. Clarity is key: a commit should be clear even to a viewer who doesn’t have the full context in which it was made.
  2. Start your commit message with a verb, and use sentence case capitalization.
  3. Use the imperative verb when writing a commit message (see the link above if you don’t know what that means). Example: "Fixed" → "Fix"
  4. Commit things that make sense to be grouped in a single commit. Ask yourself "does it make sense for someone to cherry pick this single commit? Is there something missing in it, or something extra that the person wouldn't need?" - if you do that, you'll end up aiming for 1 commit per fix or feature, which makes the codebase cleaner.
  5. Test what you are fixing before committing. Only commit what you’ve tested and are sure that is good to go. This avoids unnecessary commits fixing the same single issue.
  6. If you're using smart commits, don’t commit only the JIRA ticket identifier 😢 The viewer would have to open JIRA to know what that commit was for.
  7. Avoid commit messages like “WIP”, this is not helpful at all. Wait until you have completed a task worth committing for. It shouldn't take you multiple days to have code worth committing anyway.
  8. Unpopular opinion: never ever rewrite git history. No exceptions. No force pushes, no remote git squashing (local is fine). IMO git should be treated as a reliable, permanent and immutable stream of data, like a blockchain, and thus should never be modified.
  9. Lastly, this is not required but try to make your commit messages short (under 70 characters, extra kudos if it's under 50 as recommended by git). This enforces the commit message to be succinct enough, and avoids doing a single commit for multiple completely unrelated issues.

Remember: the ultimate goal is a git history that’s easy to read and completely self-explanatory.

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