Introduction¶
Gitlint checks your commit messages for style.
Great for use as a commit-msg git hook or as part of your gating script in a CI pipeline.
pip install gitlint
Successfully installed gitlint-core, gitlint
# Add a bad commit message
git commit --allow-empty -m " WIP: My bad commit title." -m "who cares "
[main a9f9368] WIP: My bad commit title.
# Run gitlint!
gitlinte
1: T3 Title has trailing punctuation (.): " WIP: My bad commit title."
1: T5 Title contains the word 'WIP' (case-insensitive): " WIP: My bad commit title."
1: T6 Title has leading whitespace: " WIP: My bad commit title."
3: B2 Line has trailing whitespace: "who cares "
3: B3 Line contains hard tab characters (\t): "who cares "
3: B5 Body message is too short (10<20): "who cares " # Gitlint is perfect for use in your CI pipeline. # Also available as a commit-msg hook or via pre-commit.
1: T5 Title contains the word 'WIP' (case-insensitive): " WIP: My bad commit title."
1: T6 Title has leading whitespace: " WIP: My bad commit title."
3: B2 Line has trailing whitespace: "who cares "
3: B3 Line contains hard tab characters (\t): "who cares "
3: B5 Body message is too short (10<20): "who cares " # Gitlint is perfect for use in your CI pipeline. # Also available as a commit-msg hook or via pre-commit.
Features¶
- Commit message hook: Auto-trigger validations against new commit message right when you're committing. Also works with pre-commit.
- Perfect for CI: Gitlint is designed to work with your own scripts or CI system.
- Community contributed rules: Conventions that are common but not universal can be selectively enabled.
- User-defined rules: Want to do more then what gitlint offers out of the box? Write your own user defined rules.
- Sane defaults: Many of gitlint's validations are based on well-known, community, standards, others are based on checks that we've found useful throughout the years.
- Easily configurable: Gitlint has sane defaults, but you can also easily customize it to your own liking.
- Full unicode support: Lint your Chinese or Emoji commit messages with ease!
- Production-ready: Gitlint checks a lot of the boxes you're looking for: actively maintained, full unit test coverage, integration tests, python code standards (black, ruff), good documentation, widely used, proven track record.