File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 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
2538See 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.
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ COMMIT_MSG_FILE=$1
3+ exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE || true
You can’t perform that action at this time.
0 commit comments