Debian Codegraph @

docs/commands/init.md

raw
1 The `cz init` command helps you set up Commitizen in your project by creating a configuration file with your preferred settings.
2
3 ## Usage
4
5 ![cz init --help](../images/cli_help/cz_init___help.svg)
6
7 ## Command
8
9 ```sh
10 cz init
11 ```
12
13 ## Interactive Configuration
14
15 When you run `cz init`, Commitizen will guide you through an interactive setup process:
16
17 ![init](../images/cli_interactive/init.gif)
18
19 ## Configuration File
20
21 The initialization process will create a configuration file in your project root.
22
23 See [Configuration File][configuration_file] for more details.
24
25 ## Configuration Options
26
27 During the initialization process, you'll be prompted to configure the following settings:
28
29 1. **Convention Rules**: Select the commit message convention to follow (e.g., conventional commits)
30 2. **Version Provider**: Choose how to manage versioning in your project. Commitizen supports multiple version management systems:
31 - `commitizen`: Uses Commitizen's built-in version management system
32 - `npm`: Manages version in `package.json` for Node.js projects
33 - `cargo`: Manages version in `Cargo.toml` for Rust projects
34 - `composer`: Manages version in `composer.json` for PHP projects
35 - `pep621`: Uses `pyproject.toml` with PEP 621 standard
36 - `poetry`: Uses `pyproject.toml` with Poetry configuration
37 - `uv`: Uses `pyproject.toml` and `uv.lock` for Python projects
38 - `scm`: Reads version directly from git tags without modifying files
39 3. **Project Version**: The current version of your project will be detected automatically
40 4. **Tag Format**: The format used for version tags in your repository
41 5. **Version Type**: Choose between:
42 - `semver` or `semver2`: Semantic Versioning (MAJOR.MINOR.PATCH)
43 - `pep440`: Python Package Versioning
44 6. **Changelog Generation**: Configure whether to automatically generate changelog during version bumps
45 7. **Alpha Versioning**: Option to keep major version at 0 for alpha/beta software
46 8. **Pre-commit Hooks**: Set up Git hooks for automated commit message validation. If neither `pre-commit` nor `prek` is on PATH, the hook question is skipped. If you choose to install hooks, Commitizen uses whichever of those tools is available. If both are installed, you are asked which one to use.
47
48 See [Configuration Options][configuration_options] for more details.
49
50 ## Example
51
52 ```sh
53 # Start the initialization process
54 cz init
55
56 # Follow the interactive prompts to configure your project
57 ```
58
59 ## Next Steps
60
61 After initialization, you can:
62
63 1. Start using [`cz commit`](./commit.md) to create conventional commits
64 2. Use [`cz bump`](./bump.md) to manage versioning
65 3. Configure additional settings in your project's [configuration_file][configuration_file]
66
67 [configuration_file]: ../config/configuration_file.md
68 [configuration_options]: ../config/option.md