What are Git hooks?

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.

HookRunsUse
pre-commitBefore a commitLint or test the code
commit-msgAfter the message is writtenCheck the message format
pre-pushBefore a pushRun 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.


Learn more about the similar topics:
Tutorials
Git Tag
Git Submodule
Git Hooks
Exercises & Assignments
Create an annotated tag for a release
Interview Questions & Answers
What is a git submodule?
What is the difference between a lightweight tag and an annotated tag in Git?
What are Git hooks?
What is git blame?
What is git bisect?