Table of Contents

What are Git Hooks?

About

hooks 1) is an extension system of Git to execute executable file implemented by external party (ie not Git) that run at specified steps of a command.

Location

There are two groups:

Client

Server

Workflows / List

Push

Hooks triggered during a push

The working directory is the git dir.

Others

The whole list is available online here

Location

All hooks are stored in the hooks subdirectory of the git directory location that contains already examples.

List of examples:

ls -1 .git/hooks
applypatch-msg.sample*
commit-msg.sample*
fsmonitor-watchman.sample*
post-update.sample*
pre-applypatch.sample*
pre-commit.sample*
pre-merge-commit.sample*
pre-push.sample*
pre-rebase.sample*
pre-receive.sample*
prepare-commit-msg.sample*
push-to-checkout.sample*
sendemail-validate.sample*
update.sample*

The location can be changed via the core.hooksPath configuration

git config core.hooksPath

Execution

Working Directory

The working directory is

Arguments

Hooks can get their arguments via:

Copy Hooks from server

git init may copy hooks to the new repository, depending on its configuration. See the TEMPLATE DIRECTORY section