Skip to content

Commit 0fbd8e9

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

File tree

1 file changed

+43
-32
lines changed

1 file changed

+43
-32
lines changed

docs/commands/commit.md

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,63 @@
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 conventional 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+
## Basic Usage
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+
### Interactive Commit Creation
1613

17-
## Usage
14+
Simply run `cz commit` in your terminal to start the interactive commit creation process. The command will guide you through creating a properly formatted conventional commit message.
1815

19-
![cz commit --help](../images/cli_help/cz_commit___help.svg)
16+
### Writing Messages to File
17+
18+
You can save the generated commit message to a file using:
19+
```sh
20+
cz commit --write-message-to-file COMMIT_MSG_FILE
21+
```
22+
23+
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).
2024

21-
### git options
25+
## Advanced Features
2226

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:
27+
### Git Command Options
28+
29+
You can pass any git commit options using the `--` syntax:
2530
```sh
2631
cz commit <commitizen-args> -- <git-cli-args>
2732

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

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.
38+
!!! warning
39+
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.
3540

36-
### Retry
41+
### Retry Functionality
3742

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.
43+
- Use `cz commit --retry` to reuse the last commit message after a failed commit attempt
44+
- Set `retry_after_failure: true` in your configuration to automatically retry
45+
- Use `cz commit --no-retry` to force a new commit message prompt
4246

43-
### Commit message length limit
47+
### Message Length Control
4448

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.
49+
Control the length of your commit messages using the `-l` or `--message-length-limit` option:
50+
```sh
51+
cz commit -l 72 # Limits message length to 72 characters
52+
```
53+
54+
!!! note
55+
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.
4956

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.
57+
## Technical Notes
58+
59+
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).
60+
61+
## Command Help
62+
63+
![cz commit --help](../images/cli_help/cz_commit___help.svg)

0 commit comments

Comments
 (0)