blob: 626703f91bab15eb65531c452bcb6192419a2d7a [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamano818f7d62006-03-26 01:49:306<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229/* Workarounds for IE6's broken and incomplete CSS2. */
230
231div.sidebar-content {
232 background: #ffffee;
233 border: 1px solid silver;
234 padding: 0.5em;
235}
236div.sidebar-title, div.image-title {
237 font-family: sans-serif;
238 font-weight: bold;
239 margin-top: 0.0em;
240 margin-bottom: 0.5em;
241}
242
243div.listingblock div.content {
244 border: 1px solid silver;
245 background: #f4f4f4;
246 padding: 0.5em;
247}
248
249div.quoteblock-content {
250 padding-left: 2.0em;
251}
252
253div.exampleblock-content {
254 border-left: 2px solid silver;
255 padding-left: 0.5em;
256}
257</style>
258<title>Hooks used by git</title>
259</head>
260<body>
261<div id="header">
262<h1>Hooks used by git</h1>
263</div>
264<div id="preamble">
265<div class="sectionbody">
266<p>Hooks are little scripts you can place in <tt>$GIT_DIR/hooks</tt>
267directory to trigger action at certain points. When
268<tt>git-init-db</tt> is run, a handful example hooks are copied in the
269<tt>hooks</tt> directory of the new repository, but by default they are
270all disabled. To enable a hook, make it executable with `chmod</p>
271<p>+x`.</p>
272<p>This document describes the currently defined hooks.</p>
273</div>
274</div>
275<h2>applypatch-msg</h2>
276<div class="sectionbody">
277<p>This hook is invoked by <tt>git-applypatch</tt> script, which is
278typically invoked by <tt>git-applymbox</tt>. It takes a single
279parameter, the name of the file that holds the proposed commit
280log message. Exiting with non-zero status causes the
281<em>git-applypatch</em> to abort before applying the patch.</p>
282<p>The hook is allowed to edit the message file in place, and can
283be used to normalize the message into some project standard
284format (if the project has one). It can also be used to refuse
285the commit after inspecting the message file.</p>
286<p>The default applypatch-msg hook, when enabled, runs the
287commit-msg hook, if the latter is enabled.</p>
288</div>
289<h2>pre-applypatch</h2>
290<div class="sectionbody">
291<p>This hook is invoked by <tt>git-applypatch</tt> script, which is
292typically invoked by <tt>git-applymbox</tt>. It takes no parameter,
293and is invoked after the patch is applied, but before a commit
294is made. Exiting with non-zero status causes the working tree
295after application of the patch not committed.</p>
296<p>It can be used to inspect the current working tree and refuse to
297make a commit if it does not pass certain test.</p>
298<p>The default pre-applypatch hook, when enabled, runs the
299pre-commit hook, if the latter is enabled.</p>
300</div>
301<h2>post-applypatch</h2>
302<div class="sectionbody">
303<p>This hook is invoked by <tt>git-applypatch</tt> script, which is
304typically invoked by <tt>git-applymbox</tt>. It takes no parameter,
305and is invoked after the patch is applied and a commit is made.</p>
306<p>This hook is meant primarily for notification, and cannot affect
307the outcome of <tt>git-applypatch</tt>.</p>
308</div>
309<h2>pre-commit</h2>
310<div class="sectionbody">
311<p>This hook is invoked by <tt>git-commit</tt>, and can be bypassed
312with <tt>--no-verify</tt> option. It takes no parameter, and is
313invoked before obtaining the proposed commit log message and
314making a commit. Exiting with non-zero status from this script
315causes the <tt>git-commit</tt> to abort.</p>
316<p>The default pre-commit hook, when enabled, catches introduction
317of lines with trailing whitespaces and aborts the commit when
318a such line is found.</p>
319</div>
320<h2>commit-msg</h2>
321<div class="sectionbody">
322<p>This hook is invoked by <tt>git-commit</tt>, and can be bypassed
323with <tt>--no-verify</tt> option. It takes a single parameter, the
324name of the file that holds the proposed commit log message.
325Exiting with non-zero status causes the <tt>git-commit</tt> to
326abort.</p>
327<p>The hook is allowed to edit the message file in place, and can
328be used to normalize the message into some project standard
329format (if the project has one). It can also be used to refuse
330the commit after inspecting the message file.</p>
331<p>The default commit-msg hook, when enabled, detects duplicate
332Signed-off-by: lines, and aborts the commit when one is found.</p>
333</div>
334<h2>post-commit</h2>
335<div class="sectionbody">
336<p>This hook is invoked by <tt>git-commit</tt>. It takes no
337parameter, and is invoked after a commit is made.</p>
338<p>This hook is meant primarily for notification, and cannot affect
339the outcome of <tt>git-commit</tt>.</p>
340<p>The default post-commit hook, when enabled, demonstrates how to
341send out a commit notification e-mail.</p>
342</div>
343<h2>update</h2>
344<div class="sectionbody">
Junio C Hamano818f7d62006-03-26 01:49:30345<p>This hook is invoked by <tt>git-receive-pack</tt> on the remote repository,
346which is happens when a <tt>git push</tt> is done on a local repository.
347Just before updating the ref on the remote repository, the update hook
348is invoked. It's exit status determins the success or failure of
349the ref update.</p>
350<p>The hook executes once for each ref to be updated, and takes
351three parameters:
352 - the name of the ref being updated,
353 - the old object name stored in the ref,
354 - and the new objectname to be stored in the ref.</p>
355<p>A zero exit from the update hook allows the ref to be updated.
356Exiting with a non-zero status prevents <tt>git-receive-pack</tt>
357from updating the ref.</p>
358<p>This hook can be used to prevent <em>forced</em> update on certain refs by
Junio C Hamano1a4e8412005-12-27 08:17:23359making sure that the object name is a commit object that is a
360descendant of the commit object named by the old object name.
Junio C Hamano818f7d62006-03-26 01:49:30361That is, to enforce a "fast forward only" policy.</p>
362<p>It could also be used to log the old..new status. However, it
363does not know the entire set of branches, so it would end up
364firing one e-mail per ref when used naively, though.</p>
365<p>Another use suggested on the mailing list is to use this hook to
Junio C Hamano1a4e8412005-12-27 08:17:23366implement access control which is finer grained than the one
367based on filesystem group.</p>
368<p>The standard output of this hook is sent to /dev/null; if you
369want to report something to the git-send-pack on the other end,
370you can redirect your output to your stderr.</p>
371</div>
372<h2>post-update</h2>
373<div class="sectionbody">
Junio C Hamano818f7d62006-03-26 01:49:30374<p>This hook is invoked by <tt>git-receive-pack</tt> on the remote repository,
375which is happens when a <tt>git push</tt> is done on a local repository.
376It executes on the remote repository once after all the refs have
377been updated.</p>
378<p>It takes a variable number of parameters, each of which is the
379name of ref that was actually updated.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23380<p>This hook is meant primarily for notification, and cannot affect
381the outcome of <tt>git-receive-pack</tt>.</p>
Junio C Hamano818f7d62006-03-26 01:49:30382<p>The post-update hook can tell what are the heads that were pushed,
383but it does not know what their original and updated values are,
384so it is a poor place to do log old..new.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23385<p>The default post-update hook, when enabled, runs
386<tt>git-update-server-info</tt> to keep the information used by dumb
Junio C Hamano818f7d62006-03-26 01:49:30387transports (eg, http) up-to-date. If you are publishing
388a git repository that is accessible via http, you should
389probably enable this hook.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23390<p>The standard output of this hook is sent to /dev/null; if you
391want to report something to the git-send-pack on the other end,
392you can redirect your output to your stderr.</p>
393</div>
394<div id="footer">
395<div id="footer-text">
Junio C Hamano818f7d62006-03-26 01:49:30396Last updated 26-Mar-2006 01:49:03 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23397</div>
398</div>
399</body>
400</html>