You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-45
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,8 @@ When you commit with Commitizen, you'll be prompted to fill out any required com
7
7
8
8
## Installing the command line tool
9
9
10
-
Commitizen is currently tested against
11
-
node 10 and 12 although it may work in
12
-
older node. You should also have npm 6
13
-
or greater.
10
+
Commitizen is currently tested against Node.js 10 and 12 although it may work in
11
+
older versions of Node.js. You should also have npm 6 or greater.
14
12
15
13
Installation is as simple as running the following command (if you see `EACCES` error, reading [fixing npm permissions](https://docs.npmjs.com/getting-started/fixing-npm-permissions) may help):
16
14
@@ -20,11 +18,11 @@ npm install -g commitizen
20
18
21
19
## Using the command line tool
22
20
23
-
### If your repo is [Commitizen-friendly]:
21
+
### If your repo is [Commitizenfriendly](#making-your-repo-commitizen-friendly):
24
22
25
23
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`.
26
24
27
-
_Alternatively_, if you are using **NPM 5.2+** you can [use `npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) instead of installing globally:
25
+
_Alternatively_, if you are using **npm 5.2+** you can [use `npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) instead of installing globally:
28
26
29
27
```sh
30
28
npx cz
@@ -39,19 +37,19 @@ or as an npm script:
39
37
}
40
38
```
41
39
42
-
When you're working in a Commitizenfriendly 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.
40
+
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.
43
41
44
42
[](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png)
45
43
46
44
### If your repo is NOT Commitizen friendly:
47
45
48
-
If you're **not** working in a Commitizenfriendly repository, then `git cz` will work just the same as `git commit` but `npx cz` will use the [streamich/git-cz](https://github.com/streamich/git-cz) adapter. To fix this, you need to first [make your repo Commitizen-friendly](#making-your-repo-commitizen-friendly)
46
+
If you're **not** working in a Commitizen-friendly repository, then `git cz` will work just the same as `git commit`, but `npx cz` will use the [streamich/git-cz](https://github.com/streamich/git-cz) adapter. To fix this, you need to first [make your repo Commitizenfriendly](#making-your-repo-commitizen-friendly)
49
47
50
-
## Making your repo Commitizen-friendly
48
+
## Making your repo Commitizenfriendly
51
49
52
-
For this example, we'll be setting up our repo to use [AngularJS's commit message convention](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) also known as [conventional-changelog](https://github.com/ajoslin/conventional-changelog).
50
+
For this example, we'll be setting up our repo to use [AngularJS's commit message convention](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines), also known as [conventional-changelog](https://github.com/ajoslin/conventional-changelog).
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`.
73
71
74
-
The above command does three things for you.
72
+
The above command does three things for you:
75
73
76
74
1. Installs the cz-conventional-changelog adapter npm module
77
-
2. Saves it to package.json's dependencies or devDependencies
78
-
3. Adds the `config.commitizen` key to the root of your **package.json** as shown here:
75
+
2. Saves it to `package.json`'s `dependencies` or `devDependencies`
76
+
3. Adds the `config.commitizen` key to the root of your `package.json` file as shown here:
79
77
80
78
```json
81
79
...
@@ -86,7 +84,7 @@ The above command does three things for you.
86
84
}
87
85
```
88
86
89
-
Alternatively, commitizen configs may be added to a .czrc file:
87
+
Alternatively, Commitizen configs may be added to a `.czrc` file:
90
88
91
89
```json
92
90
{
@@ -96,33 +94,33 @@ Alternatively, commitizen configs may be added to a .czrc file:
96
94
97
95
This just tells Commitizen which adapter we actually want our contributors to use when they try to commit to this repo.
98
96
99
-
`commitizen.path` is resolved via [require.resolve](https://nodejs.org/api/globals.html#globals_require_resolve) and supports
97
+
`commitizen.path` is resolved via [require.resolve](https://nodejs.org/api/globals.html#globals_require_resolve) and supports:
100
98
101
99
- npm modules
102
100
- directories relative to `process.cwd()` containing an `index.js` file
103
-
- file base names relative to `process.cwd()` with `js` extension
101
+
- file base names relative to `process.cwd()` with `.js` extension
104
102
- full relative file names
105
-
- absolute paths.
103
+
- absolute paths
106
104
107
-
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.
105
+
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.
108
106
109
107
### Optional: Install and run Commitizen locally
110
108
111
109
Installing and running Commitizen locally allows you to make sure that developers are running the exact same version of Commitizen on every machine.
112
110
113
111
Install Commitizen with `npm install --save-dev commitizen`.
114
112
115
-
On **NPM 5.2+** you can [use `npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) to initialize the conventional changelog adapter:
113
+
On **npm 5.2+** you can [use `npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) to initialize the conventional changelog adapter:
For **previous versions of NPM (< 5.2)** you can execute `./node_modules/.bin/commitizen` or `./node_modules/.bin/cz` in order to actually use the commands.
119
+
For **previous versions of npm (< 5.2)** you can execute `./node_modules/.bin/commitizen` or `./node_modules/.bin/cz` in order to actually use the commands.
122
120
123
121
You can then initialize the conventional changelog adapter using: `./node_modules/.bin/commitizen init cz-conventional-changelog --save-dev --save-exact`
124
122
125
-
And you can then add some nice npm run scripts in your package.jsonpointing to the local version of commitizen:
123
+
And you can then add some nice npm scripts in your `package.json` file pointing to the local version of Commitizen:
126
124
127
125
```json
128
126
...
@@ -133,9 +131,9 @@ And you can then add some nice npm run scripts in your package.json pointing to
133
131
134
132
This will be more convenient for your users because then if they want to do a commit, all they need to do is run `npm run commit` and they will get the prompts needed to start a commit!
135
133
136
-
> **NOTE:**if you are using `precommit` hooks thanks to something like [`husky`](https://www.npmjs.com/package/husky), you will need to name your script some thing other than `"commit"`
137
-
> (e.g. `"cm": "cz"`). The reason is because npm-scripts has a "feature" where it automatically runs scripts with the name _prexxx_ where _xxx_ is the name of another script. In essence,
138
-
> npm and husky will run `"precommit"` scripts twice if you name the script `"commit"`, and the work around is to prevent the npm-triggered _precommit_ script.
134
+
> **NOTE:**If you are using `precommit` hooks thanks to something like [`husky`](https://www.npmjs.com/package/husky), you will need to name your script something other than `"commit"`
135
+
> (e.g. `"cm": "cz"`). The reason is because npmscripts has a "feature" where it automatically runs scripts with the name _prexxx_ where _xxx_ is the name of another script. In essence,
136
+
> npm and husky will run `"precommit"` scripts twice if you name the script `"commit"`, and the workaround is to prevent the npm-triggered _precommit_ script.
For `husky` users, add the following configuration to the project's `package.json`:
158
+
For `husky` users, add the following configuration to the project's `package.json` file:
161
159
162
160
```json
163
161
"husky": {
@@ -169,19 +167,19 @@ For `husky` users, add the following configuration to the project's `package.jso
169
167
170
168
> **Why `exec < /dev/tty`?** By default, git hooks are not interactive. This command allows the user to use their terminal to interact with Commitizen during the hook.
171
169
172
-
#### Congratulations your repo is Commitizen-friendly. Time to flaunt it!
170
+
#### Congratulations! Your repo is Commitizenfriendly. Time to flaunt it!
173
171
174
-
Add the Commitizen-friendly badge to your README using the following markdown:
172
+
Add the "Commitizenfriendly" badge to your README using the following markdown:
It may also make sense to change your README.md or CONTRIBUTING.md to include or link to the Commitizen project so that your new contributors may learn more about installing and using Commitizen.
182
+
It may also make sense to change your `README.md` or `CONTRIBUTING.md` files to include or link to the Commitizen project so that your new contributors may learn more about installing and using Commitizen.
185
183
186
184
## Conventional commit messages as a global utility
187
185
@@ -191,30 +189,29 @@ Install `commitizen` globally, if you have not already.
191
189
npm install -g commitizen
192
190
```
193
191
194
-
Install your preferred `commitizen` adapter globally, for example [`cz-conventional-changelog`](https://www.npmjs.com/package/cz-conventional-changelog)
192
+
Install your preferred `commitizen` adapter globally (for example [`cz-conventional-changelog`](https://www.npmjs.com/package/cz-conventional-changelog)).
195
193
196
194
```sh
197
195
npm install -g cz-conventional-changelog
198
196
```
199
197
200
-
Create a `.czrc` file in your `home` directory, with `path` referring to the preferred, globallyinstalled, `commitizen` adapter
198
+
Create a `.czrc` file in your `home` directory, with `path` referring to the preferred, globally-installed, `commitizen` adapter
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.
204
+
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.
207
205
208
-
Protip: You can use all the `git commit``options` with `git cz`, for example: `git cz -a`.
206
+
Pro tip: You can use all the `git commit``options` with `git cz`. For example: `git cz -a`.
209
207
210
-
> If your repository is a [nodejs](https://nodejs.org/en/) project, making it [Commitizen-friendly] is super easy.
208
+
> If your repository is a [Node.js](https://nodejs.org/en/) project, making it [Commitizenfriendly](#making-your-repo-commitizen-friendly) is super easy.
211
209
212
-
If your repository is already [Commitizen-friendly], the local `commitizen` adapter will be used, instead of globally installed one.
210
+
If your repository is already [Commitizenfriendly](#making-your-repo-commitizen-friendly), the local `commitizen` adapter will be used, instead of globally installed one.
213
211
214
212
## Commitizen for multi-repo projects
215
213
216
-
As a project maintainer of many projects, you may want to standardize on a single commit message
217
-
format for all of them. You can create your own node module which acts as front-end for commitizen.
214
+
As a project maintainer of many projects, you may want to standardize on a single commit message format for all of them. You can create your own node module which acts as a front-end for Commitizen.
We know that every project and build process has different requirements so we've tried to keep Commitizen open for extension. You can do this by choosing from any of the pre-build adapters or even by building your own. Here are some of the great adapters available to you:
261
+
We know that every project and build process has different requirements, so we've tried to keep Commitizen open for extension. You can do this by choosing from any of the pre-built adapters or even by building your own. Here are some of the great adapters available to you:
To create an adapter, just fork one of these great adapters and modify it to suit your needs. We pass you an instance of [Inquirer.js](https://github.com/SBoudrias/Inquirer.js/) but you can capture input using whatever means necessary. Just call the `commit` callback with a string and we'll be happy. Publish it to npm, and you'll be all set!
281
+
To create an adapter, just fork one of these great adapters and modify it to suit your needs. We pass you an instance of [Inquirer.js](https://github.com/SBoudrias/Inquirer.js/), but you can capture input using whatever means necessary. Just call the `commit` callback with a string and we'll be happy. Publish it to npm, and you'll be all set!
285
282
286
283
## Retrying failed commits
287
284
288
285
As of version 2.7.1, you may attempt to retry the last commit using the `git cz --retry` command. This can be helpful when you have tests set up to run via a git precommit hook. In this scenario, you may have attempted a Commitizen commit, painstakingly filled out all of the commitizen fields, but your tests fail. In previous Commitizen versions, after fixing your tests, you would be forced to fill out all of the fields again. Enter the retry command. Commitizen will retry the last commit that you attempted in this repo without you needing to fill out the fields again.
289
286
290
-
Please note that the retry cache may be cleared when upgrading commitizen versions, upgrading adapters, or if you delete the `commitizen.json` file in your home or temp directory. Additionally, the commit cache uses the filesystem path of the repo, so if you move a repo or change its path, you will not be able to retry a commit. This is an edge case, but might be confusing if you have scenarios where you are moving folders that contain repos.
287
+
Please note that the retry cache may be cleared when upgrading Commitizen versions, upgrading adapters, or if you delete the `commitizen.json` file in your home or temp directory. Additionally, the commit cache uses the filesystem path of the repo, so if you move a repo or change its path, you will not be able to retry a commit. This is an edge case but might be confusing if you have scenarios where you are moving folders that contain repos.
291
288
292
-
It is important to note that if you are running `cz` from a npm script (let's say it is called `commit`) you will need to do one of the following:
289
+
It is important to note that if you are running `cz` from an npm script (let's say it is called `commit`) you will need to do one of the following:
293
290
294
291
- Pass `-- --retry` as an argument for your script. i.e: `npm run commit -- --retry`
295
-
- Use [npx](https://www.npmjs.com/package/npx) to find and call `cz` executable directly. i.e: `npx cz --retry`
292
+
- Use [npx](https://www.npmjs.com/package/npx) to find and call the `cz` executable directly. i.e: `npx cz --retry`
296
293
297
294
Note that the last two options **do not** require you to pass `--` before the args but the first **does**.
298
295
@@ -302,7 +299,7 @@ As a project maintainer, making your repo Commitizen friendly allows you to sele
302
299
303
300
## Go further
304
301
305
-
Commitizen is great on its own, but it shines when you use it with some other amazing open source tools. Kent C. Dodds shows you how to accomplish this in his Egghead.io series, [How to write an open source javascript library](https://egghead.io/series/how-to-write-an-open-source-javascript-library). Many of the concepts can be applied to non-javascript projects as well.
302
+
Commitizen is great on its own, but it shines when you use it with some other amazing open source tools. Kent C. Dodds shows you how to accomplish this in his Egghead.io series, [How to write an open source javascript library](https://egghead.io/series/how-to-write-an-open-source-javascript-library). Many of the concepts can be applied to non-JavaScript projects as well.
0 commit comments