Usage
「cz-git」 requires Node >=v12.20
As a dev dependency use
Just three simple steps:
TIP
global installation commitizen, that you can quickly use the cz or git cz command to start.
sh
npm install -g commitizennpm install -g commitizen- Install dependenciessh
npm install -D cz-gitnpm install -D cz-gitshyarn add -D cz-gityarn add -D cz-gitshpnpm install -D cz-gitpnpm install -D cz-git - Modify
package.jsonto addconfigSpecify the adapter usedjson{ "scripts": { }, "config": { "commitizen": { "path": "node_modules/cz-git" } } }{ "scripts": { }, "config": { "commitizen": { "path": "node_modules/cz-git" } } } - (Optional, use default) Add custom configuration
👇 There are two configuration methods
- (Recommend) cz-git is linked with commitlint to provide verification information, so it can be written in commitlint configuration file.
E.g: (⇒ Configuration Template)
js// .commitlintrc.js /** @type {import('cz-git').UserConfig} */ module.exports = { rule: { ... }, prompt: { useEmoji: true //option... } }// .commitlintrc.js /** @type {import('cz-git').UserConfig} */ module.exports = { rule: { ... }, prompt: { useEmoji: true //option... } }- Add custom configuration under config.commitizen under
package.json, but excessive configuration items will lead to bloated package.json, which is suitable for simple customization. E.g:
json{ "scripts": { "commit": "git-cz" }, "config": { "commitizen": { "path": "node_modules/cz-git", "useEmoji": true } } }{ "scripts": { "commit": "git-cz" }, "config": { "commitizen": { "path": "node_modules/cz-git", "useEmoji": true } } } - (Recommend) cz-git is linked with commitlint to provide verification information, so it can be written in commitlint configuration file.
As global use
The advantage of global installation is that you can use
czorgit czcommand to start command line tools under any project to generate standardized commit messages
Just three simple steps:
- Install global dependenciessh
npm install -g cz-git commitizennpm install -g cz-git commitizen - Global configuration adapter typesh
echo '{ "path": "cz-git", "$schema": "https://raw.githubusercontent.com/Zhengqbbb/cz-git/refs/tags/v1.12.0/docs/public/schema/cz-git.json" }' > ~/.czrcecho '{ "path": "cz-git", "$schema": "https://raw.githubusercontent.com/Zhengqbbb/cz-git/refs/tags/v1.12.0/docs/public/schema/cz-git.json" }' > ~/.czrc - (Optional, use default) Add custom configuration
👇 There are two configuration methods
- Edit the
~/.czrcfile to add configuration in the form ofJSON, for example:
json{ "path": "cz-git", "useEmoji": true }{ "path": "cz-git", "useEmoji": true }- Cooperate with commitlint to create a configuration file under the path of
$HOME
(↓ Configuration Template)
- Edit the
cz-git