Git Hooks/Commit-msg conventional commits validator

Reject non-conforming commit messages.

Section: Hook Snippets

Commit-msg conventional commits validator

sh
bash
#!/usr/bin/env sh
grep -Eq "^(feat|fix|docs|chore|refactor|test)(\(.+\))?: .+" "$1"

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Hook Snippets
Pre-commit lint script
Run linting before commit and fail on error.
OpenIn sheetshsame section
Pre-commit test script
Run tests before commit.
OpenIn sheetshsame section
Block direct pushes to main
Prevent accidental pushes to main.
OpenIn sheetshsame section
Post-checkout regenerate assets
Run setup after checkout when needed.
OpenIn sheetshsame section
Commit-msg hook path
Default path for commit-msg hook script.
OpenIn sheetsh2 tag match
Pre-commit hook path
Default path for pre-commit hook script.
OpenIn sheetsh1 tag match