Configuration¶
Gitlint provides multiple ways to configure its behavior:
.gitlint
file (Recommended)- CLI flags and environment variables
- Config in your commit message
- Configuration Rules
Quick start¶
.gitlint
[general]
# Ignore rules, reference them by id or name (comma-separated)
ignore=title-trailing-punctuation, T3
# Enable specific community contributed rules
contrib=contrib-title-conventional-commits,CC1
# Set the extra-path where gitlint will search for user defined rules
extra-path=./gitlint_rules/my_rules.py
### Configuring rules ### (1)
[title-max-length]
line-length=80
[title-min-length]
min-length=5
- Configure the behavior of a specific rule by adding a section for it to the ini file.
Rules can be referenced by their full name or by id. For example, the rule[title-max-length]
could also be referenced as[T1]
.
# Change gitlint's verbosity.
$ gitlint -v
# Ignore certain rules
$ gitlint --ignore body-is-missing,T3
# Enable debug mode
$ gitlint --debug
# Load user-defined rules
$ gitlint --extra-path /home/joe/mygitlint_rules
# Set any config option using -c
$ gitlint -c general.verbosity=2 -c title-max-length.line-length=80
Configuration precedence¶
Gitlint configuration is applied in the following order of precedence:
- Commit specific config (e.g.:
gitlint-ignore: all
in the commit message) - Configuration Rules (e.g.: ignore-by-title)
- Commandline convenience flags (e.g.:
-vv
,--silent
,--ignore
) - Environment variables (e.g.:
GITLINT_VERBOSITY=3
) - Commandline configuration flags (e.g.:
-c title-max-length=123
) - Configuration file (local
.gitlint
file, or file specified using-C
/--config
) - Default gitlint config