Git Hooks
Set up and manage git hooks with vis for your team
Git Hooks
vis provides built-in git hook management as a lightweight alternative to tools like husky.
Getting Started
Installing Hooks
vis hook installThis configures core.hooksPath to point to your hooks directory (.vis-hooks by default).
Creating a Hook
Create executable scripts in the hooks directory:
echo '#!/bin/sh
pnpm run lint-staged' > .vis-hooks/pre-commit
chmod +x .vis-hooks/pre-commitCommit the Hooks Directory
Add the hooks directory to version control so the entire team shares the same hooks:
git add .vis-hooks/
git commit -m "chore: add git hooks"Migrating from Husky
If your project currently uses husky, vis can automatically migrate your hooks:
vis hook migrateThe migration:
- Detects your husky directory (
.huskyor.husky/_) - Copies all hook scripts to the vis hooks directory
- Prompts for confirmation before making changes
- Removes the husky directory after migration
Disabling Hooks
Temporarily disable hooks using the environment variable:
VIS_GIT_HOOKS=0 git commit -m "skip hooks"For debugging hook issues:
VIS_GIT_HOOKS=2 git commit -m "debug hooks"Common Hook Recipes
Lint Staged Files
#!/bin/sh
# .vis-hooks/pre-commit
pnpm run lint-stagedValidate Commit Messages
#!/bin/sh
# .vis-hooks/commit-msg
pnpm run commitlint --edit "$1"Run Type Checks Before Push
#!/bin/sh
# .vis-hooks/pre-push
pnpm run typecheckCheck Dependencies Before Commit
#!/bin/sh
# .vis-hooks/pre-commit
vis check --exit-code --format minimal || {
echo "Outdated dependencies detected. Run 'vis check' for details."
exit 1
}Uninstalling
To remove vis hooks and reset git's core.hooksPath:
vis hook uninstall