Skip to content

Commit bcddb21

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

File tree

1 file changed

+45
-31
lines changed

1 file changed

+45
-31
lines changed

docs/commands/commit.md

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,66 @@
1+
2+
## Usage
3+
4+
![cz commit --help](../images/cli_help/cz_commit___help.svg)
5+
6+
## Overview
7+
18
![Using Commitizen cli](../images/demo.gif)
29

3-
## About
10+
The `commit` command provides an interactive way to create structured commits. Use either:
411

5-
In your terminal run `cz commit` or the shortcut `cz c` to generate a guided git commit.
12+
- `cz commit`
13+
- `cz c` (shortcut)
614

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).
15+
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.
1116

17+
## Basic Usage
1218

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).
19+
### Interactive Commit Creation
1620

17-
## Usage
21+
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.
1822

19-
![cz commit --help](../images/cli_help/cz_commit___help.svg)
23+
### Writing Messages to File
24+
25+
You can save the generated commit message to a file using:
26+
```sh
27+
cz commit --write-message-to-file COMMIT_MSG_FILE
28+
```
29+
30+
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).
2031

21-
### git options
32+
## Advanced Features
2233

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:
34+
### Git Command Options
35+
36+
You can pass any git commit options using the `--` syntax:
2537
```sh
2638
cz commit <commitizen-args> -- <git-cli-args>
2739

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

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.
45+
!!! warning
46+
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.
3547

3648
### Retry
3749

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

43-
### Commit message length limit
54+
### Message Length Control
55+
56+
Control the length of your commit messages using the `-l` or `--message-length-limit` option:
57+
```sh
58+
cz commit -l 72 # Limits message length to 72 characters
59+
```
60+
61+
!!! note
62+
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.
4463

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.
64+
## Technical Notes
4965

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.
66+
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).

0 commit comments

Comments
 (0)