Skip to content
On this page

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

Step 1: Install dependencies

sh
npm install -D cz-git
npm install -D cz-git
sh
yarn add -D cz-git
yarn add -D cz-git
sh
pnpm install -D cz-git
pnpm install -D cz-git

Step 2: Modify package.json to add config Specify the adapter used

json
{
  "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)

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...
  }
}

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:

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
    }
  }
}

As global use

The advantage of global installation is that you can use cz or git cz command to start command line tools under any project to generate standardized commit messages

Just three simple steps:

Step 1: Install global dependencies

sh
npm install -g cz-git commitizen
npm install -g cz-git commitizen

Step 2: Global configuration adapter type

sh
echo '{ "path": "cz-git", "$schema": "https://cdn.jsdelivr.net/gh/Zhengqbbb/cz-git@1.8.0/docs/public/schema/cz-git.json" }' > ~/.czrc
echo '{ "path": "cz-git", "$schema": "https://cdn.jsdelivr.net/gh/Zhengqbbb/cz-git@1.8.0/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:

json
{
  "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)

I just try my best to make thing well, Could you give a star ⭐