Document hooks.
[git/git.git] / Documentation / hooks.txt
CommitLineData
6d35cc76
JH
1Hooks used by GIT
2=================
3v0.99.6, Sep 2005
4
5Hooks are little scripts you can place in `$GIT_DIR/hooks`
6directory to trigger action at certain points. When
7`git-init-db` is run, a handful example hooks are copied in the
8`hooks` directory of the new repository, but by default they are
9all disabled. To enable a hook, make it executable with `chmod
10+x`.
11
12This document describes the currently defined hooks.
13
14applypatch-msg
15--------------
16
17This hook is invoked by `git-applypatch` script, which is
18typically invoked by `git-applymbox`. It takes a single
19parameter, the name of the file that holds the proposed commit
20log message. Exiting with non-zero status causes the
21'git-applypatch' to abort before applying the patch.
22
23The hook is allowed to edit the message file in place, and can
24be used to normalize the message into some project standard
25format (if the project has one). It can also be used to refuse
26the commit after inspecting the message file.
27
28The default applypatch-msg hook, when enabled, runs the
29commit-msg hook, if the latter is enabled.
30
31pre-applypatch
32--------------
33
34This hook is invoked by `git-applypatch` script, which is
35typically invoked by `git-applymbox`. It takes no parameter,
36and is invoked after the patch is applied, but before a commit
37is made. Exiting with non-zero status causes the working tree
38after application of the patch not committed.
39
40It can be used to inspect the current working tree and refuse to
41make a commit if it does not pass certain test.
42
43The default pre-applypatch hook, when enabled, runs the
44pre-commit hook, if the latter is enabled.
45
46post-applypatch
47---------------
48
49This hook is invoked by `git-applypatch` script, which is
50typically invoked by `git-applymbox`. It takes no parameter,
51and is invoked after the patch is applied and a commit is made.
52
53This hook is meant primarily for notification, and cannot affect
54the outcome of `git-applypatch`.
55
56pre-commit
57----------
58
59This hook is invoked by `git-commit-script`, and can be bypassed
60with `--no-verify` option. It takes no parameter, and is
61invoked before obtaining the proposed commit log message and
62making a commit. Exiting with non-zero status from this script
63causes the `git-commit-script` to abort.
64
65The default pre-commit hook, when enabled, catches introduction
66of lines with trailing whitespaces and aborts the commit when
67a such line is found.
68
69commit-msg
70----------
71
72This hook is invoked by `git-commit-script`, and can be bypassed
73with `--no-verify` option. It takes a single parameter, the
74name of the file that holds the proposed commit log message.
75Exiting with non-zero status causes the `git-commit-script` to
76abort.
77
78The hook is allowed to edit the message file in place, and can
79be used to normalize the message into some project standard
80format (if the project has one). It can also be used to refuse
81the commit after inspecting the message file.
82
83The default commit-msg hook, when enabled, detects duplicate
84Signed-off-by: lines, and aborts the commit when one is found.
85
86post-commit
87-----------
88
89This hook is invoked by `git-commit-script`. It takes no
90parameter, and is invoked after a commit is made.
91
92This hook is meant primarily for notification, and cannot affect
93the outcome of `git-commit-script`.
94
95The default post-commit hook, when enabled, demonstrates how to
96send out a commit notification e-mail.
97
98update
99------
100
101This hook is invoked by `git-receive-pack`, which is invoked
102when a `git push` is done against the repository. It takes
103three parameters, name of the ref being updated, old object name
104stored in the ref, and the new objectname to be stored in the
105ref. Exiting with non-zero status from this hook prevents
106`git-receive-pack` from updating the ref.
107
108This can be used to prevent 'forced' update on certain refs by
109making sure that the object name is a commit object that is a
110descendant of the commit object named by the old object name.
111Another use suggested on the mailing list is to use this hook to
112implement access control which is finer grained than the one
113based on filesystem group.
114
115post-update
116-----------
117
118This hook is invoked by `git-receive-pack`, which is invoked
119when a `git push` is done against the repository. It takes
120variable number of parameters; each of which is the name of ref
121that was actually updated.
122
123This hook is meant primarily for notification, and cannot affect
124the outcome of `git-receive-pack`.
125
126The default post-update hook, when enabled, runs
127`git-update-server-info` to keep the information used by dumb
128transport up-to-date.