Git hooks are scripts in the folder .git/hooks which Git runs before or after events such as commit, merge or push. If a “pre” hook exits with an error, Git stops the action.
Hook
Runs
Use
pre-commit
Before a commit
Lint or test the code
commit-msg
After the message is written
Check the message format
pre-push
Before a push
Run the full tests
Hooks are not shared by git push. Teams keep them in a folder and use git config core.hooksPath .githooks, or tools like Husky. See Git Hooks.