Git provides both server- and client-side hooks that allow custom actions to be taken on events. Generally,
pre-* hooks can intercept operations by exiting with a non-zero status, and
post-* hooks are well suited to sending notifications.
Hooks can be relocated from the default
.git/hooks directory with the
core.hooksPath option, allowing them to be kept under version control.
prepare-commit-msgexecutes between the generation of the default commit message and the editor starting, allowing customisation of the message. It receives one to three arguments:
- The commit message file path.
- The contents of the
git commit, or
squashif it's a merge or squash commit.
- The commit reference if amending an existing commit.
pre-commitis invoked before a commit is created, allowing verification of its contents.
pre-receivereceives new objects and is able to determine whether or not to accept them.
post-receiveis useful for triggering a build or deployment of a website with a static site generator.