Git hooks are shell scripts placed in .git/hooks/ that git executes automatically on certain events - before a commit is finalised, before a push, after a checkout, and so on. They're commonly used to perform tasks like running a linter, validating commit message format, or blocking a push to a protected branch. These are exactly the things you want applied consistently across every developer on a project (or even just across your own computers) but the problem is that .git/hooks/ is not committed to the repo - so by default, every developer starts with nothing and is expected to wire it all up themselves.
There are various ways to approach this issue, some of the common ones are:
- The hand-written
core.hooksPathapproach - Husky
- pre-commit
- Lefthook