Volbrene – Git Hooks helps you keep your commit messages consistent and enforce Conventional Commits automatically.
- ✅ Automatic ticket reference – parses branch names like
feature/IT-1234and prefixes commit messages. - ✅ Conventional Commits support – supports
feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert. - ✅ Fallback handling – unknown branch prefixes default to
chore(...). - ✅ Easy setup – installs hooks automatically via
npm install.
Make sure you have Node.js (>=16) and npm installed, then run:
npm install --save-dev volbrene-git-hooksAfter that, initialize the hooks with:
npx volbrene-git-hooks initThis will add a prepare script to your package.json:
With this in place, the hooks will be automatically reinstalled whenever you (or your team) run npm install.
The following Git hooks are installed in the hooks directory when the package is installed:
This hook automatically rewrites commit messages based on your current branch name.
- If you are on
feature/IT-1234, and run:
git commit -m "add new button"It will rewrite the commit message to:
feat(IT-1234): add new button
Supported branch prefixes:
| Branch Prefix | Resulting Commit Type |
|---|---|
feature/*, feat/* |
feat(...) |
bug/*, bugfix/*, fix/*, hotfix/* |
fix(...) |
docs/* |
docs(...) |
style/* |
style(...) |
refactor/* |
refactor(...) |
perf/*, performance/* |
perf(...) |
test/*, tests/* |
test(...) |
build/* |
build(...) |
ci/* |
ci(...) |
revert/* |
revert(...) |
task/* or unknown |
chore(...) |
Installs or re-installs the Git hooks for the current repository.
- Ensures
.git/hooksexists - Copies the
prepare-commit-msghook from this package into.git/hooks
Resets Git’s core.hooksPath back to the default .git/hooks folder.
- Unsets any custom
core.hooksPath(e.g. from Husky or other tools) - Sets the local repository back to
.git/hooks - Prints the effective hook directory for verification
Removes all installed Git hooks and unsets core.hooksPath.
- Deletes the
.git/hooksfolder (or the directory configured incore.hooksPath) - Attempts to unset
core.hooksPath(ignored if not set) - Useful for clean-up or before switching to another hook manager
Sets up automatic hook installation on npm install.
- Adds
"prepare": "volbrene-git-hooks"to yourpackage.jsonscripts - Ensures hooks will be installed for every developer after
npm install - Recommended for teams to keep hooks consistent
- Copies the
prepare-commit-msghook from this package into.git/hooks
Shows usage information and a list of available commands.