Brad Woods Digital Garden

Notes / Misc / Git / Commit message convention

The Warhammer 40k Adeptus Mechanicus symbol

Table of contents

    A circle

    Git Commit Message Convention

    Planted: 

    Tended: 

    Status: decay

    Hits: 122

    Conventional Commits is a convention for adding human and machine readable meaning to commit messages.

    Why

    • Improves a team's shared understanding of a codebase by better communicating what a commit did through:
      • structure,
      • clarity (through use of keywords) and
      • consistency.
    • Makes it easier to write automated tools on top of:
      • automatically generating CHANGELOGs,
      • automatically determining a semantic version bump (based on the types of commits landed) and
      • triggering build and publish processes based on commit type.

    Structure

    The convention structures a commit with 2 mandatory fields and 3 optional.

    > <type>[scope]: <description>> [body]> [footer(s)]_

    Examples

    A bug fix

    > git commit -m "fix: broken home link"_

    A new feature with a breaking change

    In Bash, you can use single quotes to write a message on multiple lines.

    > git commit -m 'feat: add user-data API endpoint> > BREAKING CHANGE: remove user-name endpoint'_

    A new feature with scope provided

    > git commit -m "feat(user-profile): add user-avatar API endpoint"_
    A wizard attempting to open a magic door at the base of a mountain.

    Message Keywords

    Key WordIndicatesCorrelates with SemVer
    buildBuild system changes
    ciCI configuration changes
    docsDocumentation changes
    featIntroduce a new featureMINOR v1.0.0 -> v1.1.0
    fixPatch a bugPATCH v1.0.0 -> v1.0.1
    perfPerformance improvements
    testAdd missing / correct tests
    refactor
    BREAKING CHANGEIntroduce a breaking API changeMAJOR v1.0.0 -> v2.0.0

    Information about SemVer can be found here.

    Feedback

    Have any feedback about this note or just want to comment on the state of the economy?