gitlint
Lint Git commit messages for style and correctness
TLDR
Check the last commit message
The range of commits to lint
Path to a directory or Python module with extra user-defined rules
Start a specific CI job
Path to a file containing a commit-msg
Read staged commit meta-info from the local repository
SYNOPSIS
gitlint [-h|-V] [-v|-vv] [-C PATH] [--config FILE] [--color {auto|never|always}] [--warnings-as-errors] [--fix] [--editor] [--staged] [--commit-msg-file FILE] [--commits REV_RANGE] [PATH]
PARAMETERS
-h, --help
Show help message and exit
-V, --version
Display gitlint version
-v, --verbose
Verbose output; use -vv for more details
-C PATH
Run in specific Git repository
--config FILE
Load configuration from YAML file
--color {auto|never|always}
Control colored output
--warnings-as-errors
Treat warnings as errors (exit code 1)
--fix
Auto-fix body lines exceeding 72 characters
--editor
Open editor for staged commit message if invalid
--staged
Lint only the staged commit message
--commit-msg-file FILE
Lint message from specific file
--commits REV_RANGE
Lint commits in given revision range
--install-hook
Install Git hooks in current repo
--uninstall-hook
Uninstall Git hooks
--init
Initialize gitlint config and hooks
DESCRIPTION
gitlint is a command-line tool that enforces conventional commit message standards in Git repositories.
It checks commit messages against a set of built-in rules (e.g., body max line length, title max length, no todo) and supports custom rules via configuration.
Run it manually with gitlint, integrate via Git hooks (gitlint --install-hook), or use as a pre-commit hook. It supports linting the last commit, staged changes, specific revisions, or message files.
Features include auto-fixing minor issues, colorized output, verbose modes, and extensibility. Ideal for teams enforcing clean histories, it outputs human-readable diagnostics with rule IDs for quick fixes.
CAVEATS
Requires Python and installation via pip install gitlint; not a core Git command. Custom rules need YAML config. Hooks may conflict with other tools.
INSTALLATION
Install with pip install gitlint or via package managers like Homebrew (brew install gitlint). Add gitlint --install-hook for automatic enforcement.
CONFIGURATION
Edit ~/.gitlint or .gitlint.yml to enable/disable rules, e.g., rules: - T001: level: warning.
RULES
Over 20 built-in rules like T001 (title max 50 chars), B003 (body line <72 chars), CA01 (no TODO). List with gitlint --rules.
HISTORY
Created by Joris van der Wel in 2017 as an alternative to commitlint. Actively maintained on GitHub; version 0.20+ added rule customization and hook improvements. Widely used in CI/CD pipelines.
SEE ALSO
git(1), git-commit(1), git-log(1)


