Hooks live in .git/hooks, where git init leaves 14 disabled examples such as pre-commit.sample. A hook is enabled by giving a file the exact event name, with no extension, and making it executable. 14 follows one commit and one push. The pre- hooks and commit-msg run before Git 1,932 changes anything and can veto the operation; the post- hooks run afterward and can only report.

| Hook | Runs when | Can block | Typical use |
|---|---|---|---|
| pre-commit | Before the message is asked for | Yes | Lint and test staged files |
| commit-msg | After the message is written | Yes | Enforce a message style |
| pre-push | Before objects are sent | Yes | Run the slower test suite |
| pre-receive, update | On the server, before refs move | Yes | Policy no client can skip |
| post-receive | On the server, after refs move | No | Notify, deploy, trigger CI |
A hook can be any executable (shell, Node.js 2,131 , Python), runs at the top of the working tree, and can be run by hand with git hook run pre-commit. The hooks directory is never cloned or pushed: otherwise any repository you cloned could run programs on your machine. Sharing hooks takes a deliberate step (core.hooksPath).