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