Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4e28075

Browse files
committed
docs(prepare-commit-msg): add additional information to tutorial
1 parent 14fac5b commit 4e28075

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎docs/tutorials/auto_prepare_commit_message.md‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@
22

33
## About
44

5-
To automatically prepare a commit message prior to committing, you can use a [Git hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks).
5+
It can be desirable to use commitizen for all types of commits (i.e. regular, merge,
6+
squash) so that the complete git history adheres to the commit message convention
7+
without ever having to call `cz commit` manually.
8+
9+
To automatically prepare a commit message prior to committing, you can
10+
use a [Git hook](prepare-commit-msg-docs):
11+
12+
> The [prepare-commit-msg] hook is invoked by git-commit right after preparing the
13+
> default log message, and before the editor is started.
14+
15+
This allows for enforcing the usage of commitizen so that whenever a commit is about to
16+
be created, commitizen is used for creating the commit message. Running `git commit` or
17+
`git commit -m "..."` for example, would trigger commitizen and use the generated commit
18+
message for the commit.
619

720
## How to
821

@@ -25,3 +38,8 @@ exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE
2538
See the Git hooks documentation on [`prepare-commit-msg` hooks][prepare-commit-msg-docs] for details on how this works.
2639

2740
[prepare-commit-msg-docs]: https://git-scm.com/docs/githooks#_prepare_commit_msg
41+
42+
## Drawbacks
43+
44+
If additional hooks are used (e.g. pre-commit) that prevent a commit from being created,
45+
the message has to be created from scratch when commiting again.

‎hooks/prepare-commit-msg.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
COMMIT_MSG_FILE=1ドル
3+
exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE || true

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /