Global configuration
Commitlint
Section titled “Commitlint”Commitlint can install a global configuration for you. You can do so by running the following command:
commitlint install --global
This will place a commitlint.yml
in one of the following locations:
~/.config/commitlint/commitlint.yml
c:/Users/<username>/AppData/Roaming/commitlint/commitlint.yml
Alongside the configuration file a hooks
folder is created with a default commit-msg
hook.
To use the hook you need to add a global hooks directory to your git config.
To automatically register the commitlint hooks directory to your git config you can use the --register-hooks
flag alongside the --global
flag:
commitlint install --global --register-hooks
Or manually using the following command:
git config --global core.hooksPath ~/.config/commitlint/hooks
git config --global core.hooksPath c:/Users/<username>/AppData/Roaming/commitlint/hooks
Or add the path to your gitconfig:
[core] hooksPath = ~/.config/commitlint/hooks
[core] hooksPath = c:/Users/<username>/AppData/Roaming/commitlint/hooks
Custom hooks path
Section titled “Custom hooks path”You can also use a custom path for your hooks. Ensure you have a commit-msg hook with the following content:
#!/bin/shcat $1 | commitlint
This will ensure that commitlint is run on every commit message.
After that you can run the following command to add the hooks directory to your git config:
git config --global core.hooksPath <your git hooks path>
Or add the path to your gitconfig:
[core] hooksPath = <your git hooks path>