Skip to content

Commit 0e15249

Browse files
committed
docs(commit): rewrite command commit page
1 parent aaa64ac commit 0e15249

File tree

1 file changed

+44
-31
lines changed

1 file changed

+44
-31
lines changed

docs/commands/commit.md

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,65 @@
11
![Using Commitizen cli](../images/demo.gif)
22

3-
## About
3+
## Overview
44

5-
In your terminal run `cz commit` or the shortcut `cz c` to generate a guided git commit.
5+
The `commit` command provides an interactive way to create structured commits. Use either:
66

7-
You can run `cz commit --write-message-to-file COMMIT_MSG_FILE` to additionally save the
8-
generated message to a file. This can be combined with the `--dry-run` flag to only
9-
write the message to a file and not modify files and create a commit. A possible use
10-
case for this is to [automatically prepare a commit message](../tutorials/auto_prepare_commit_message.md).
7+
- `cz commit`
8+
- `cz c` (shortcut)
119

10+
By default, Commitizen uses conventional commits, but you can customize the commit rules to match your project's needs. See the [customization guide](../customization.md) for details.
1211

13-
!!! note
14-
To maintain platform compatibility, the `commit` command disable ANSI escaping in its output.
15-
In particular pre-commit hooks coloring will be deactivated as discussed in [commitizen-tools/commitizen#417](https://github.com/commitizen-tools/commitizen/issues/417).
12+
## Basic Usage
1613

17-
## Usage
14+
### Interactive Commit Creation
1815

19-
![cz commit --help](../images/cli_help/cz_commit___help.svg)
16+
Simply run `cz commit` in your terminal to start the interactive commit creation process. The command will guide you through creating a properly formatted commit message according to your configured rules.
2017

21-
### git options
18+
### Writing Messages to File
2219

23-
`git` command options that are not implemented by Commitizen can be use via the `--` syntax for the `commit` command.
24-
The syntax separates Commitizen arguments from `git commit` arguments by a double dash. This is the resulting syntax:
20+
You can save the generated commit message to a file using:
21+
```sh
22+
cz commit --write-message-to-file COMMIT_MSG_FILE
23+
```
24+
25+
This can be combined with `--dry-run` to only write the message without creating a commit. This is particularly useful for [automatically preparing commit messages](../tutorials/auto_prepare_commit_message.md).
26+
27+
## Advanced Features
28+
29+
### Git Command Options
30+
31+
You can pass any git commit options using the `--` syntax:
2532
```sh
2633
cz commit <commitizen-args> -- <git-cli-args>
2734

28-
# e.g., cz commit --dry-run -- -a -S
35+
# Examples:
36+
cz c --dry-run -- -a -S # Stage all changes and sign the commit
37+
cz c -a -- -n # Stage all changes and skip the pre-commit and commit-msg hooks
2938
```
30-
For example, using the `-S` option on `git commit` to sign a commit is now Commitizen compatible: `cz c -- -S`
3139

32-
!!! note
33-
Deprecation warning: A commit can be signed off using `cz commit --signoff` or the shortcut `cz commit -s`.
34-
This syntax is now deprecated in favor of the new `cz commit -- -s` syntax.
40+
!!! warning
41+
The `--signoff` option (or `-s`) is now recommended being used with the new syntax: `cz commit -- -s`. The old syntax `cz commit --signoff` is deprecated.
3542

3643
### Retry
3744

38-
You can use `cz commit --retry` to reuse the last commit message when the previous commit attempt failed.
39-
To automatically retry when running `cz commit`, you can set the `retry_after_failure`
40-
configuration option to `true`. Running `cz commit --no-retry` makes Commitizen ignore `retry_after_failure`, forcing
41-
a new commit message to be prompted.
45+
- Use `cz commit --retry` to reuse the last commit message after a failed commit attempt
46+
- Set `retry_after_failure: true` in your configuration to automatically retry
47+
- Use `cz commit --no-retry` to force a new commit message prompt
4248

43-
### Commit message length limit
49+
### Message Length Control
4450

45-
The argument `-l` (or `--message-length-limit`) followed by a positive number can limit the length of commit messages.
46-
An exception would be raised when the message length exceeds the limit.
47-
For example, `cz commit -l 72` will limit the length of commit messages to 72 characters.
48-
By default, the limit is set to 0, which means no limit on the length.
51+
Control the length of your commit messages using the `-l` or `--message-length-limit` option:
52+
```sh
53+
cz commit -l 72 # Limits message length to 72 characters
54+
```
55+
56+
!!! note
57+
The length limit only applies to the first line of the commit message. For conventional commits, this means the limit applies from the type of change through the subject. The body and footer are not counted.
4958

50-
**Note that the limit applies only to the first line of the message.**
51-
Specifically, for `ConventionalCommitsCz` the length only counts from the type of change to the subject,
52-
while the body and the footer are not counted.
59+
## Technical Notes
60+
61+
For platform compatibility, the `commit` command disables ANSI escaping in its output. This means pre-commit hooks coloring will be deactivated as discussed in [commitizen-tools/commitizen#417](https://github.com/commitizen-tools/commitizen/issues/417).
62+
63+
## Command Help
64+
65+
![cz commit --help](../images/cli_help/cz_commit___help.svg)

0 commit comments

Comments
 (0)