Do something before or after a particular action
- Server-side hooks: we can't use them because of Github. Use webhooks instead
- Client-side hooks:
- 'git am' hooks: we don't use 'am', so we don't care
- Commit:
- post-commit
- commit-msg
- prepare-commit-msg
- pre-commit
- Others
- pre-rebase
- post-checkout
- post-merge
- pre-push
- pre-auto-gc
- post-rewrite
# everything you need to know about each hook
man githooks
- Hooks are stored in
.git/hooks/
in your repo - Hooks can be scripts in any language, and can run any programs available on the system
Example pre-commit hook to lint code, stored in .git/hooks/pre-commit
#!/usr/bin/bash --login
eslint ./lib