Git hook scripts with Conventional Commits enforcement
npm install volbrene-git-hooks


> Volbrene β Git Hooks helps you keep your commit messages consistent and enforce Conventional Commits automatically.
---
- β
Automatic ticket reference β parses branch names like feature/IT-1234 and 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:
``sh`
npm install --save-dev volbrene-git-hooks
After that, initialize the hooks with:
`sh`
npx volbrene-git-hooks init
This will add a prepare script to your package.json:
`jsonc`
"scripts": {
"prepare": "volbrene-git-hooks"
}
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:
`bash`
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/hooks existsprepare-commit-msg
- Copies the hook 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).git/hooks
- Sets the local repository back to
- Prints the effective hook directory for verification
Removes all installed Git hooks and unsets core.hooksPath.
- Deletes the .git/hooks folder (or the directory configured in core.hooksPath)core.hooksPath
- Attempts to unset (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 your package.json scriptsnpm install
- Ensures hooks will be installed for every developer after prepare-commit-msg
- Recommended for teams to keep hooks consistent
- Copies the hook from this package into .git/hooks
Shows usage information and a list of available commands.