mergetool: Fix typo in options passed to kdiff3
[git/mergetool.git] / Documentation / hooks.txt
blobc39edc57c4452091e2f313cb8d5cfa9d51a4b27b
1 Hooks used by git
2 =================
4 Hooks are little scripts you can place in `$GIT_DIR/hooks`
5 directory to trigger action at certain points.  When
6 `git-init` 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 +x`.
10 This document describes the currently defined hooks.
12 applypatch-msg
13 --------------
15 This hook is invoked by `git-am` script.  It takes a single
16 parameter, the name of the file that holds the proposed commit
17 log message.  Exiting with non-zero status causes
18 `git-am` to abort before applying the patch.
20 The hook is allowed to edit the message file in place, and can
21 be used to normalize the message into some project standard
22 format (if the project has one). It can also be used to refuse
23 the commit after inspecting the message file.
25 The default 'applypatch-msg' hook, when enabled, runs the
26 'commit-msg' hook, if the latter is enabled.
28 pre-applypatch
29 --------------
31 This hook is invoked by `git-am`.  It takes no parameter,
32 and is invoked after the patch is applied, but before a commit
33 is made.  Exiting with non-zero status causes the working tree
34 after application of the patch not committed.
36 It can be used to inspect the current working tree and refuse to
37 make a commit if it does not pass certain test.
39 The default 'pre-applypatch' hook, when enabled, runs the
40 'pre-commit' hook, if the latter is enabled.
42 post-applypatch
43 ---------------
45 This hook is invoked by `git-am`.  It takes no parameter,
46 and is invoked after the patch is applied and a commit is made.
48 This hook is meant primarily for notification, and cannot affect
49 the outcome of `git-am`.
51 pre-commit
52 ----------
54 This hook is invoked by `git-commit`, and can be bypassed
55 with `\--no-verify` option.  It takes no parameter, and is
56 invoked before obtaining the proposed commit log message and
57 making a commit.  Exiting with non-zero status from this script
58 causes the `git-commit` to abort.
60 The default 'pre-commit' hook, when enabled, catches introduction
61 of lines with trailing whitespaces and aborts the commit when
62 such a line is found.
64 commit-msg
65 ----------
67 This hook is invoked by `git-commit`, and can be bypassed
68 with `\--no-verify` option.  It takes a single parameter, the
69 name of the file that holds the proposed commit log message.
70 Exiting with non-zero status causes the `git-commit` to
71 abort.
73 The hook is allowed to edit the message file in place, and can
74 be used to normalize the message into some project standard
75 format (if the project has one). It can also be used to refuse
76 the commit after inspecting the message file.
78 The default 'commit-msg' hook, when enabled, detects duplicate
79 "Signed-off-by" lines, and aborts the commit if one is found.
81 post-commit
82 -----------
84 This hook is invoked by `git-commit`.  It takes no
85 parameter, and is invoked after a commit is made.
87 This hook is meant primarily for notification, and cannot affect
88 the outcome of `git-commit`.
90 [[pre-receive]]
91 pre-receive
92 -----------
94 This hook is invoked by `git-receive-pack` on the remote repository,
95 which happens when a `git push` is done on a local repository.
96 Just before starting to update refs on the remote repository, the
97 pre-receive hook is invoked.  Its exit status determines the success
98 or failure of the update.
100 This hook executes once for the receive operation. It takes no
101 arguments, but for each ref to be updated it receives on standard
102 input a line of the format:
104   <old-value> SP <new-value> SP <ref-name> LF
106 where `<old-value>` is the old object name stored in the ref,
107 `<new-value>` is the new object name to be stored in the ref and
108 `<ref-name>` is the full name of the ref.
109 When creating a new ref, `<old-value>` is 40 `0`.
111 If the hook exits with non-zero status, none of the refs will be
112 updated. If the hook exits with zero, updating of individual refs can
113 still be prevented by the <<update,'update'>> hook.
115 Both standard output and standard error output are forwarded to
116 `git-send-pack` on the other end, so you can simply `echo` messages
117 for the user.
119 [[update]]
120 update
121 ------
123 This hook is invoked by `git-receive-pack` on the remote repository,
124 which happens when a `git push` is done on a local repository.
125 Just before updating the ref on the remote repository, the update hook
126 is invoked.  Its exit status determines the success or failure of
127 the ref update.
129 The hook executes once for each ref to be updated, and takes
130 three parameters:
132  - the name of the ref being updated,
133  - the old object name stored in the ref,
134  - and the new objectname to be stored in the ref.
136 A zero exit from the update hook allows the ref to be updated.
137 Exiting with a non-zero status prevents `git-receive-pack`
138 from updating that ref.
140 This hook can be used to prevent 'forced' update on certain refs by
141 making sure that the object name is a commit object that is a
142 descendant of the commit object named by the old object name.
143 That is, to enforce a "fast forward only" policy.
145 It could also be used to log the old..new status.  However, it
146 does not know the entire set of branches, so it would end up
147 firing one e-mail per ref when used naively, though.  The
148 <<post-receive,'post-receive'>> hook is more suited to that.
150 Another use suggested on the mailing list is to use this hook to
151 implement access control which is finer grained than the one
152 based on filesystem group.
154 Both standard output and standard error output are forwarded to
155 `git-send-pack` on the other end, so you can simply `echo` messages
156 for the user.
158 The default 'update' hook, when enabled--and with
159 `hooks.allowunannotated` config option turned on--prevents
160 unannotated tags to be pushed.
162 [[post-receive]]
163 post-receive
164 ------------
166 This hook is invoked by `git-receive-pack` on the remote repository,
167 which happens when a `git push` is done on a local repository.
168 It executes on the remote repository once after all the refs have
169 been updated.
171 This hook executes once for the receive operation.  It takes no
172 arguments, but gets the same information as the
173 <<pre-receive,'pre-receive'>>
174 hook does on its standard input.
176 This hook does not affect the outcome of `git-receive-pack`, as it
177 is called after the real work is done.
179 This supersedes the <<post-update,'post-update'>> hook in that it gets
180 both old and new values of all the refs in addition to their
181 names.
183 Both standard output and standard error output are forwarded to
184 `git-send-pack` on the other end, so you can simply `echo` messages
185 for the user.
187 The default 'post-receive' hook is empty, but there is
188 a sample script `post-receive-email` provided in the `contrib/hooks`
189 directory in git distribution, which implements sending commit
190 emails.
192 [[post-update]]
193 post-update
194 -----------
196 This hook is invoked by `git-receive-pack` on the remote repository,
197 which happens when a `git push` is done on a local repository.
198 It executes on the remote repository once after all the refs have
199 been updated.
201 It takes a variable number of parameters, each of which is the
202 name of ref that was actually updated.
204 This hook is meant primarily for notification, and cannot affect
205 the outcome of `git-receive-pack`.
207 The 'post-update' hook can tell what are the heads that were pushed,
208 but it does not know what their original and updated values are,
209 so it is a poor place to do log old..new. The
210 <<post-receive,'post-receive'>> hook does get both original and
211 updated values of the refs. You might consider it instead if you need
212 them.
214 When enabled, the default 'post-update' hook runs
215 `git-update-server-info` to keep the information used by dumb
216 transports (e.g., HTTP) up-to-date.  If you are publishing
217 a git repository that is accessible via HTTP, you should
218 probably enable this hook.
220 Both standard output and standard error output are forwarded to
221 `git-send-pack` on the other end, so you can simply `echo` messages
222 for the user.