Commitizen: Is it possible to override the "git commit" command?

Asked

Viewed 84 times

0

Context

I wish I could use the command git commit and be executed the cz.

What happens

  1. I install the Commitzen
  2. Executed git commit
  3. Opens the common Git interface to create the commit message

What I would like

  1. I install the Commitzen
  2. Executed git commit
  3. Opens the Commitzen interface

1 answer

0


I ended up finding the documentation of the tool and found that there are two ways, being them:

Changing the Git hook

Open the file .git/hooks/prepare-commit-msg and put the code down:

#!/bin/bash
exec < /dev/tty && node_modules/.bin/cz --hook || true

Changing the Git hook through the use of Husky

Before we begin, the Husky is a tool that assists in creating Git Hooks in your Node project.

For those who use Husky - just like me -, just include in your package.json:

"husky": {
  "hooks": {
    "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true",
  }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.