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 commitizen
npm install -g commitizen
- Install dependenciessh
npm install -D cz-git
npm install -D cz-git
shyarn add -D cz-git
yarn add -D cz-git
shpnpm install -D cz-git
pnpm install -D cz-git
- Modify
package.json
to addconfig
Specify 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
cz
orgit cz
command 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 commitizen
npm 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" }' > ~/.czrc
echo '{ "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
~/.czrc
file 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