Skip to main content

Git Standards

Git commit message standards following conventional commits specification.

Here at Carcosa, we’re following conventional commits specification in writing commit messages. Having a coherent and standardized commit structure help us involved in a project understand the changes that have occurred and write them easier.

Structure

The commit message should be structured as follows:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Types

Commits MUST be prefixed with a type, which consists of a noun, feat, fix, etc., followed by the OPTIONAL scope, OPTIONAL !, and REQUIRED terminal colon and space.

TypeMeaningDescription
featFeaturesMUST be used when a commit adds a new feature to your application or library.
fixBug FixesMUST be used when a commit represents a bug fix for your application.
styleStylesChanges that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
refactorCode RefactoringA code change that neither fixes a bug nor adds a feature
perfPerformance ImprovementsA code change that improves performance
testTestsAdding missing tests or correcting existing tests
buildBuildsChanges that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
ciContinuous IntegrationsChanges to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
choreChoresOther changes that don’t modify src or test files
revertRevertsReverts a previous commit
docsDocumentationDocumentation only changes

Description

A description should describe your changes in imperative mood. This means you need to eliminate the temptation to use gerunds or past tense in your description line. Don’t write a git commit description line that talks about what you did, or what you are doing. Instead, describe what was done. A description MUST immediately follow the colon and space after the type/scope prefix. The description is a short summary of the code changes, e.g., fix: fix the fencepost error.

Scope (optional)

A scope MAY be provided after a type. A scope MUST consist of a noun describing a section of the codebase surrounded by parenthesis, e.g., feat(ratings): add the ability to add star ratings to posts.

Breaking Changes

Breaking changes are indicated by putting BREAKING CHANGE: at the start of the message body, for any commit type. Optionally they may be emphasized by appending a ! after the type and scope. The message body should provide appropriate guidance for developers affected by the breaking change.

Examples

Commit message with no body

docs: correct spelling of CHANGELOG

Commit message with scope

feat(lang): add polish language
feat: allow provided config object to extend other configs

BREAKING CHANGE: `extends` key in config file is now used for extending other config files

Commit message with ! to draw attention to breaking change

refactor!: drop support for Node 6

Commit message with multi-paragraph body and multiple footers

fix: correct minor typos in code

see the issue for details

on typos fixed.

Reviewed-by: Z
Refs #133

Fixing up commits

If you already made commits and they don’t meet the Conventional Commits specification, you have a couple of options:

  • if there’s only one commit to redo, the easiest option is to use git commit --amend with no staged changes, which will allow you to edit the commit message.