Commitizen is currently tested against Node.js 12, 14, & 16, although it may work in older versions of Node.js. You should also have npm 6 or greater.
Installation is as simple as running the following command (if you see EACCES
error, reading fixing npm permissions may help):
npm install -g commitizen
There are two ways to use it in your repo.
Simply use git cz
or just cz
instead of git commit
when committing. You can also use git-cz
, which is an alias for cz
.
Alternatively, if you are using npm 5.2+ you can use npx
instead of installing globally:
npx cz
or as an npm script:
...
"scripts": {
"commit": "cz"
}
When you're working in a Commitizen-friendly repository, you'll be prompted to fill in any required fields, and your commit messages will be formatted according to the standards defined by project maintainers.
For this example, we'll be setting up our repo to use this adapter (cz-lissone-changelog). First, install the Commitizen CLI tools:
npm install commitizen -g
Next, initialize your project to use the cz-lissone-changelog adapter by typing:
commitizen init cz-lissone-changelog --save-dev --save-exact
Or if you are using Yarn:
commitizen init cz-lissone-changelog --yarn --dev --exact
Note that if you want to force install over the top of an old adapter, you can apply the --force
argument. For more information on this, just run commitizen help
.
The above command does three things for you:
- Installs the cz-lissone-changelog adapter npm module
- Saves it to
package.json
'sdevDependencies
- Adds the
config.commitizen
key to the root of yourpackage.json
file as shown here:
...
"config": {
"commitizen": {
"path": "cz-lissone-changelog"
}
}
Alternatively, Commitizen configs may be added to a .czrc
file:
{
"path": "cz-lissone-changelog"
}
This just tells Commitizen which adapter we actually want our contributors to use when they try to commit to this repo.
commitizen.path
is resolved via require.resolve and supports:
- npm modules
- directories relative to
process.cwd()
containing anindex.js
file - file base names relative to
process.cwd()
with.js
extension - full relative file names
- absolute paths
Please note that in the previous version of Commitizen we used czConfig. czConfig has been deprecated, and you should migrate to the new format before Commitizen 3.0.0.
Install commitizen
globally, if you have not already.
npm install -g commitizen
Install your preferred commitizen
adapter globally.
npm install -g cz-lissone-changelog
Create a .czrc
file in your home
directory, with path
referring to the preferred, globally-installed, commitizen
adapter.
echo '{ "path": "cz-lissone-changelog" }' > ~/.czrc
You are all set! Now cd
into any git
repository and use git cz
instead of git commit
, and you will find the commitizen
prompt.
Pro tip: You can use all the git commit
options
with git cz
. For example: git cz -a
.