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
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.