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.
npm install -g commitizen
npm install -g commitizen
Step 1: Install dependencies
npm install -D cz-git
npm install -D cz-git
yarn add -D cz-git
yarn add -D cz-git
pnpm install -D cz-git
pnpm install -D cz-git
Step 2: Modify package.json
to add config
Specify the adapter used
{
"scripts": {
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
}
}
{
"scripts": {
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
}
}
Step 3: Add custom configuration (optional, use default)
There are two configuration methods
Method 1: (recommended) cz-git is linked with commitlint to provide verification information, so it can be written in commitlint configuration file.
E.g: (⇒ Configuration Template)
// .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...
}
}
Method 2: 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:
{
"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
}
}
}
As global use
The advantage of global installation is that you can use
cz
orgit cz
command to start command line tools under any project to generate standardized commit messages
Just three simple steps:
Step 1: Install global dependencies
npm install -g cz-git commitizen
npm install -g cz-git commitizen
Step 2: Global configuration adapter type
echo '{ "path": "cz-git", "$schema": "https://cdn.jsdelivr.net/gh/Zhengqbbb/cz-git@1.9.4/docs/public/schema/cz-git.json" }' > ~/.czrc
echo '{ "path": "cz-git", "$schema": "https://cdn.jsdelivr.net/gh/Zhengqbbb/cz-git@1.9.4/docs/public/schema/cz-git.json" }' > ~/.czrc
Step 3: Add custom configuration (optional, use default configuration)
There are two configuration methods
Method 1: Edit the ~/.czrc
file to add configuration in the form of JSON
, for example:
{
"path": "cz-git",
"useEmoji": true
}
{
"path": "cz-git",
"useEmoji": true
}
Method 2: Cooperate with commitlint to create a configuration file under the path of $HOME
(↓ Configuration Template)