1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
# Configuration File
Commitizen uses configuration files to customize its behavior for your project. These files define settings such as which commit rules to use, version management preferences, changelog generation options, and more.
## Creating a Configuration File
It is recommended to create a configuration file via our [`cz init`](../commands/init.md) command. This command will guide you through setting up your configuration file with the appropriate settings for your project.
## File Location and Search Order
Configuration files are typically located in the root of your project directory. Commitizen searches for configuration files in the following order:
1. `pyproject.toml` (in the `[tool.commitizen]` section)
2. `.cz.toml`
3. `.cz.json`
4. `cz.json`
5. `.cz.yaml`
6. `cz.yaml`
7. `cz.toml`
The first valid configuration file found will be used. If no configuration file is found, Commitizen will use its default settings.
!!! tip
For Python projects, it's recommended to add your Commitizen configuration to `pyproject.toml` to keep all project configuration in one place.
## Supported Formats
Commitizen supports three configuration file formats:
- **TOML** (`.toml`) - Recommended for Python projects
- **JSON** (`.json`)
- **YAML** (`.yaml`)
All formats support the same configuration options. Choose the format that best fits your project's ecosystem.
## Configuration Structure
### TOML Format
For TOML files, Commitizen settings are placed under the `[tool.commitizen]` section. If you're using a standalone `.cz.toml` or `cz.toml` file, you can use `[tool.commitizen]` or just `[commitizen]`.
**Example: `pyproject.toml`, `.cz.toml` or `cz.toml`**
```toml title="pyproject.toml"
[tool.commitizen]
name = "cz_conventional_commits"
version = "0.1.0"
version_provider = "commitizen"
version_scheme = "pep440"
version_files = [
"src/__version__.py",
"pyproject.toml:version"
]
tag_format = "$version"
update_changelog_on_bump = true
changelog_file = "CHANGELOG.md"
changelog_incremental = false
bump_message = "bump: version $current_version → $new_version"
gpg_sign = false
annotated_tag = false
major_version_zero = false
prerelease_offset = 0
retry_after_failure = false
allow_abort = false
message_length_limit = 0
allowed_prefixes = [
"Merge",
"Revert",
"Pull request",
"fixup!",
"squash!",
"amend!"
]
breaking_change_exclamation_in_title = false
use_shortcuts = false
pre_bump_hooks = []
post_bump_hooks = []
encoding = "utf-8"
# Optional: Custom styling for prompts
style = [
["qmark", "fg:#ff9d00 bold"],
["question", "bold"],
["answer", "fg:#ff9d00 bold"],
["pointer", "fg:#ff9d00 bold"],
["highlighted", "fg:#ff9d00 bold"],
["selected", "fg:#cc5454"],
["separator", "fg:#cc5454"],
["instruction", ""],
["text", ""],
["disabled", "fg:#858585 italic"]
]
```
### JSON Format
For JSON files, Commitizen settings are placed under the `commitizen` key.
**Example: `.cz.json` or `cz.json`**
```json title=".cz.json"
{
"commitizen": {
"name": "cz_conventional_commits",
"version": "0.1.0",
"version_provider": "commitizen",
"version_scheme": "pep440",
"version_files": [
"src/__version__.py",
"pyproject.toml:version"
],
"tag_format": "$version",
"update_changelog_on_bump": true,
"changelog_file": "CHANGELOG.md",
"changelog_incremental": false,
"bump_message": "bump: version $current_version → $new_version",
"gpg_sign": false,
"annotated_tag": false,
"major_version_zero": false,
"prerelease_offset": 0,
"retry_after_failure": false,
"allow_abort": false,
"message_length_limit": 0,
"allowed_prefixes": [
"Merge",
"Revert",
"Pull request",
"fixup!",
"squash!",
"amend!"
],
"breaking_change_exclamation_in_title": false,
"use_shortcuts": false,
"pre_bump_hooks": [],
"post_bump_hooks": [],
"encoding": "utf-8",
"style": [
["qmark", "fg:#ff9d00 bold"],
["question", "bold"],
["answer", "fg:#ff9d00 bold"],
["pointer", "fg:#ff9d00 bold"],
["highlighted", "fg:#ff9d00 bold"],
["selected", "fg:#cc5454"],
["separator", "fg:#cc5454"],
["instruction", ""],
["text", ""],
["disabled", "fg:#858585 italic"]
]
}
}
```
### YAML Format
For YAML files, Commitizen settings are placed under the `commitizen` key.
**Example: `.cz.yaml` or `cz.yaml`**
```yaml title=".cz.yaml"
commitizen:
name: cz_conventional_commits
version: "0.1.0"
version_provider: commitizen
version_scheme: pep440
version_files:
- src/__version__.py
- pyproject.toml:version
tag_format: "$version"
update_changelog_on_bump: true
changelog_file: CHANGELOG.md
changelog_incremental: false
bump_message: "bump: version $current_version → $new_version"
gpg_sign: false
annotated_tag: false
major_version_zero: false
prerelease_offset: 0
retry_after_failure: false
allow_abort: false
message_length_limit: 0
allowed_prefixes:
- Merge
- Revert
- Pull request
- fixup!
- squash!
- amend!
breaking_change_exclamation_in_title: false
use_shortcuts: false
pre_bump_hooks: []
post_bump_hooks: []
encoding: utf-8
style:
- - qmark
- fg:#ff9d00 bold
- - question
- bold
- - answer
- fg:#ff9d00 bold
- - pointer
- fg:#ff9d00 bold
- - highlighted
- fg:#ff9d00 bold
- - selected
- fg:#cc5454
- - separator
- fg:#cc5454
- - instruction
- ""
- - text
- ""
- - disabled
- fg:#858585 italic
```
## Configuration Options
For a complete list of all available configuration options and their descriptions, see the [Configuration Settings](../config/option.md) documentation.
Key configuration categories include:
- **Commit Rules**: `name` - Select which commit convention to use
- **Version Management**: `version`, `version_provider`, `version_scheme`, `version_files`
- **Tagging**: `tag_format`, `legacy_tag_formats`, `ignored_tag_formats`, `gpg_sign`, `annotated_tag`
- **Changelog**: `changelog_file`, `changelog_format`, `changelog_incremental`, `update_changelog_on_bump`
- **Bumping**: `bump_message`, `major_version_zero`, `prerelease_offset`, `pre_bump_hooks`, `post_bump_hooks`
- **Commit Validation**: `allowed_prefixes`, `message_length_limit`, `allow_abort`, `retry_after_failure`
- **Customization**: `customize`, `style`, `use_shortcuts`, `template`, `extras`
## Customization
For advanced customization, including creating custom commit rules, see the [Customization](../customization/config_file.md) documentation.
!!! note
The `customize` option is only supported when using TOML configuration files.
|