Skip to main content

Example conventional commit message examples from the Angular project.

# Conventional commit message examples

> Conventional commit message examples from the [Angular](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#-commit-message-format) project.

## Commit message format

```plaintext
──────────────────────────────────────────── 100 chars ────────────────────────────────────────────┤
<type>(<scope>): <summary>

<Describe the motivation behind this change - explain WHY you are making this change. Wrap all lines
at 100 characters.>

Fixes #<issue number>
───────────────────────────────────────────────────────────────────────────────────────────────────┤
```

## Example commit messages

### Simple refactor

```plaintext
─── Example: Simple refactor ──────────────────────────────────────────────────────────────────────┤
refactor(core): rename refreshDynamicEmbeddedViews to refreshEmbeddedViews

Improve code readability. The original name no longer matches how the function is used.
───────────────────────────────────────────────────────────────────────────────────────────────────┤
```

### Simple docs change

```plaintext
─── Example: Simple docs change ───────────────────────────────────────────────────────────────────┤
docs: clarify the service limitation in providers.md guide

Fixes #36332
───────────────────────────────────────────────────────────────────────────────────────────────────┤
```

### A bug fix

```plaintext
─── Example: A bug fix ────────────────────────────────────────────────────────────────────────────┤
fix(ngcc): ensure lockfile is removed when `analyzeFn` fails

Previously an error thrown in the `analyzeFn` would cause the ngcc process to exit immediately
without removing the lockfile, and potentially before the unlocker process had been successfully
spawned resulting in the lockfile being orphaned and left behind.

Now we catch these errors and remove the lockfile as needed.
───────────────────────────────────────────────────────────────────────────────────────────────────┤
```

### Breaking change

```plaintext
─── Example: Breaking change ──────────────────────────────────────────────────────────────────────┤
feat(bazel): simplify ng_package by dropping esm5 and fesm5

esm5 and fesm5 distributions are no longer needed and have been deprecated in the past.

https://v9.angular.io/guide/deprecations#esm5-and-fesm5-code-formats-in-angular-npm-packages

This commit modifies ng_package to no longer distribute these two formats in npm packages built by
ng_package (e.g. @angular/core).

This commit intentionally doesn't fully clean up the ng_package rule to remove all traces of esm5
and fems5 build artifacts as that is a bigger cleanup and currently we are narrowing down the
scope of this change to the MVP needed for v10, which in this case is 'do not put esm5 and fesm5'
into the npm packages.

More cleanup to follow: https://angular-team.atlassian.net/browse/FW-2143

BREAKING CHANGE: esm5 and fesm5 format is no longer distributed in Angular's npm packages e.g.
@angular/core

Angular CLI will automatically downlevel the code to es5 if differential loading is enabled in the
Angular project, so no action is required from Angular CLI users.

If you are not using Angular CLI to build your application or library, and you need to be able to
build es5 artifacts, then you will need to downlevel the distributed Angular code to es5 on your
own.

Fixes #1234
───────────────────────────────────────────────────────────────────────────────────────────────────┤
```

## Angular commit message format

> See [full specification](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit) of the Angular commit message format.

The following is an excerpt of the specification with the most commonly needed
info.

Each commit message consists of a _header_, a _body_, and a _footer_.

```plaintext
<header>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

The header is mandatory.

The body is mandatory for all commits except for those of scope "docs". When the
body is required it must be at least 20 characters long.

The footer is optional.

Any line of the commit message cannot be longer than 100 characters.

### Commit message header

```plaintext
<type>(<scope>): <short summary>
  │       │             │
  │       │             └─⫸ Summary in present tense. Not capitalized. No period at the end.
  │       │
  │       └─⫸ Commit Scope: animations|bazel|benchpress|common|compiler|compiler-cli|core|
  │                          elements|forms|http|language-service|localize|platform-browser|
  │                          platform-browser-dynamic|platform-server|router|service-worker|
  │                          upgrade|zone.js|packaging|changelog|docs-infra|migrations|
  │                          devtools
  │
  └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test
```

The `<type>` and `<summary>` fields are mandatory, the `(<scope>)` field is optional.

#### Type

Must be one of the following:

- **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
- **ci**: Changes to our CI configuration files and scripts (examples: CircleCi, SauceLabs)
- **docs**: Documentation only changes
- **feat**: A new feature
- **fix**: A bug fix
- **perf**: A code change that improves performance
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **test**: Adding missing tests or correcting existing tests

#### Scope

The scope should be the name of the npm package affected (as perceived by the
person reading the changelog generated from commit messages).

The following is the list of supported scopes:

- `animations`
- `bazel`
- `benchpress`
- `common`
- `compiler`
- `compiler-cli`
- `core`
- `elements`
- `forms`
- `http`
- `language-service`
- `localize`
- `platform-browser`
- `platform-browser-dynamic`
- `platform-server`
- `router`
- `service-worker`
- `upgrade`
- `zone.js`

There are currently a few exceptions to the "use package name" rule:

- `packaging`: used for changes that change the npm package layout in all of our packages, e.g. public path changes, package.json changes done to all packages, d.ts file/format changes, changes to bundles, etc.
- `changelog`: used for updating the release notes in CHANGELOG.md
- `dev-infra`: used for dev-infra related changes within the directories /scripts and /tools
- `docs-infra`: used for docs-app (angular.io) related changes within the /aio directory of the repo
- `migrations`: used for changes to the `ng update` migrations.
- `devtools`: used for changes in the browser extension
- none/empty string: useful for `test` and `refactor` changes that are done across all packages (e.g. `test: add missing unit tests`) and for docs changes that are not related to a specific package (e.g. `docs: fix typo in tutorial`).

#### Short summary

Use the summary field to provide a succinct description of the change:

- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end

### Commit message body

Just as in the summary, use the imperative, present tense: "fix" not "fixed" nor "fixes".

Explain the motivation for the change in the commit message body. This commit
message should explain WHY you are making the change. You can include a
comparison of the previous behavior with the new behavior in order to illustrate
the impact of the change.

### Commit message footer

The footer can contain information about breaking changes and is also the place
to reference GitHub issues, Jira tickets, and other PRs that this commit closes
or is related to.

The footer can contain information about breaking changes and deprecations and
is also the place to reference GitHub issues, Jira tickets, and other PRs that
this commit closes or is related to.

```plaintext
BREAKING CHANGE: <breaking change summary>
<BLANK LINE>
<breaking change description + migration instructions>
<BLANK LINE>
<BLANK LINE>
Fixes #<issue number>
```

Breaking Change section should start with the phrase "BREAKING CHANGE: "
followed by a summary of the breaking change, a blank line, and a detailed
description of the breaking change that also includes migration instructions.

## References

- [Contributing to Angular: Commit message guidelines](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit)
- [angular/angular/.gitmessage](https://github.com/angular/angular/blob/main/.gitmessage)
- [snippets/conventional-commit-message-examples](https://jonlabelle.com/snippets/view/markdown/conventional-commit-message-examples)
- [gist](https://gist.github.com/jonlabelle/c0bbab253eaa30051107d363cf495c86)
- [Conventional Commit Messages](https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13)
- [Git Hook Scripts to ensure commit message header format](https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13#git-hook-scripts-to-ensure-commit-message-header-format)