File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 4343 - Tutorials :
4444 - Writing commits : " tutorials/writing_commits.md"
4545 - Auto check commits : " tutorials/auto_check.md"
46+ - Auto prepare commit message : " tutorials/auto_prepare_commit_message.md"
4647 - GitLab CI : " tutorials/gitlab_ci.md"
4748 - Github Actions : " tutorials/github_actions.md"
4849 - Jenkins pipeline : " tutorials/jenkins_pipeline.md"
You can’t perform that action at this time.
0 commit comments