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
  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
  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"
        }
      }
    }
  3. (Optional, use default) Add custom configuration

    👇 There are two configuration methods

    1. (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...
      }
    }
    1. 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:

  1. Install global dependencies
    sh
    npm install -g cz-git commitizen
    npm install -g cz-git commitizen
  2. Global configuration adapter type
    sh
    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
  3. (Optional, use default) Add custom configuration

    👇 There are two configuration methods

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