|
| 1 | +# Automatically prepare message before commit |
| 2 | + |
| 3 | +## About |
| 4 | + |
| 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). |
| 6 | + |
| 7 | +## How to |
| 8 | + |
| 9 | +- Step 1: Create a new [`prepare-commit-msg`][prepare-commit-msg-docs] Git hook by running the following commands from the root of the Git repository: |
| 10 | + |
| 11 | +```sh |
| 12 | +cd .git/hooks |
| 13 | +touch prepare-commit-msg |
| 14 | +chmod +x prepare-commit-msg |
| 15 | +``` |
| 16 | + |
| 17 | +- Step 2: Edit the newly created file and add the following content: |
| 18 | + |
| 19 | +```sh |
| 20 | +#!/bin/sh |
| 21 | +COMMIT_MSG_FILE=1ドル |
| 22 | +exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE || true |
| 23 | +``` |
| 24 | + |
| 25 | +See the Git hooks documentation on [`prepare-commit-msg` hooks][prepare-commit-msg-docs] for details on how this works. |
| 26 | + |
| 27 | +[prepare-commit-msg-docs]: https://git-scm.com/docs/githooks#_prepare_commit_msg |
0 commit comments