DEV Community

Dmitry Kalinin
Dmitry Kalinin

Posted on

Linting for your git commit messages

Alt Text

Gitlint is a git commit message linter written in python: it checks your commit messages for style.

Features

  • Commit message hook
  • Easily integrated
  • Sane defaults
  • Easily configurable
  • Community contributed rules
  • User-defined rules
  • Full unicode support
  • Production-ready

Installation

pip

#### Pip is recommended to install the latest version
pip install gitlint
Enter fullscreen mode Exit fullscreen mode

macOS

brew install gitlint
sudo port install gitlint  # alternative
Enter fullscreen mode Exit fullscreen mode

Ubuntu

apt-get install gitlint
Enter fullscreen mode Exit fullscreen mode

Docker

docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint
Enter fullscreen mode Exit fullscreen mode

Usage

# Check the last commit message
gitlint
# Alternatively, pipe a commit message to gitlint:
cat examples/commit-message-1 | gitlint
# or
git log -1 --pretty=%B | gitlint
# Or read the commit-msg from a file, like so:
gitlint --msg-filename examples/commit-message-2
# Lint all commits in your repo
gitlint --commits HEAD

# To install a gitlint as a commit-msg git hook:
gitlint install-hook
Enter fullscreen mode Exit fullscreen mode

Top comments (0)