Skip to content

Git Commit Message

Roger Xu edited this page Jun 1, 2016 · 3 revisions

Resources

Best Practices

  • short single-line summary (less than 50 characters)
  • optionally followed by a blank line and a more complete description
  • keep each line to less than 72 characters
  • write commit message in present tense, not past tense
    • "fix bug", not "fixed bug"
  • bullet points are usually hyphens
  • can add "ticket tracking numbers" from bugs or support requests
  • can develop shorthand for your organization
    • "[css,js] "
    • "bugfix: "
    • "#38405 - "
  • be clear and descriptive
    • Bad: "Fix typo"
    • Good: "Add missing > in project section of HTML"
    • Bad: "Update login code"
    • Good: "Change user authentication to use Blowfish"
    • Bad: "Updates member report, we should discuss if this is right next week"
<type>(<scope>): <subject>
// empty line
<body>
// empty line
<footer>

Each line should be less than 72 characters.

Header

type

Mandatory

  • feat
  • fix
  • docs
  • style
  • refactor
  • test
  • chore

scope

subject

Mandatory. Less than 5 characters.

  • Begin with verb. e.g., "change".
  • The first letter should be lower case.
  • No period (.) in the end

Commit Message Usage

One line for each commit

$ git log <last tag> HEAD --pretty=format:%s

Filter commits

$ git log <last release> HEAD --grep feature

Generate change log