Enforces commit message conventions through configurable rules .
(currently supports type、scope and subject validation, Additional features will be implemented gradually.)
Method 1: (Recommended)
With Rust toolchain installed:
cargo install gitruMethod 2:
Download pre-built binary:
- Get latest release for your OS
- Add to system PATH
- Set executable permissions:
Install hook and initialize configuration:
gitru commit-msg iiCommand breakdown:
ii=install(sets up git hook) +init(creates config template)- Execute separately:
gitru commit-msg installthengitru commit-msg init
After installation:
- Git hook installed to
.git/hooks/commit-msg - Configuration template created at
.commit-msg-rule.yaml
Customize validation rules by editing .commit-msg-rule.yaml.
You can optionally modify, delete, or comment out the options that do not require validation.
Validation success Example:
git commit -m "feat: add new API endpoint"
git commit -m "feat(core): add new API endpoint"Validation Failure Example:
(default config)
git commit -m "add feature"
git commit -m "feat: add" # subject 'add' is too short
git commit -m "feat:add feature" # need space default
git commit -m "feat(): add feature"
git commit -m "feat(: add feature"
git commit -m "feat): add feature"remove commit-msg hook from .git/hooks directory:
gitru commit-msg uninstallremove .commit-msg-rule.yaml file manually .