blob: c9bf5765a887a99c6dc4d80c27510be0e212641d [file] [log] [blame]
Junio C Hamano2fbcd212008-05-14 22:26:071<!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 Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
Junio C Hamano2fbcd212008-05-14 22:26:077<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
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamano2fbcd212008-05-14 22:26:0726
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
45}
46
Junio C Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamano2fbcd212008-05-14 22:26:0748 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamano2fbcd212008-05-14 22:26:0751 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamano2fbcd212008-05-14 22:26:0759
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamano2fbcd212008-05-14 22:26:0784}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
97}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
131}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamano2fbcd212008-05-14 22:26:07155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamano2fbcd212008-05-14 22:26:07166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamano2fbcd212008-05-14 22:26:07171
172div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
179}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamano2fbcd212008-05-14 22:26:07215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamano2fbcd212008-05-14 22:26:07220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamano2fbcd212008-05-14 22:26:07236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
256}
257
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamano2fbcd212008-05-14 22:26:07275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
287}
288
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamano2fbcd212008-05-14 22:26:07306</style>
307<title>githooks(5)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312githooks(5) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>githooks -
317 Hooks used by git
318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31323<div class="para"><p>$GIT_DIR/hooks/*</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07324</div>
Junio C Hamanoba4b9282008-07-06 05:20:31325<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07326<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31327<div class="para"><p>Hooks are little scripts you can place in <tt>$GIT_DIR/hooks</tt>
Junio C Hamano2fbcd212008-05-14 22:26:07328directory to trigger action at certain points. When
Junio C Hamanoba4b9282008-07-06 05:20:31329<em>git-init</em> is run, a handful example hooks are copied in the
Junio C Hamano2fbcd212008-05-14 22:26:07330<tt>hooks</tt> directory of the new repository, but by default they are
Junio C Hamano6aff3992008-06-25 08:07:44331all disabled. To enable a hook, rename it by removing its <tt>.sample</tt>
Junio C Hamanoba4b9282008-07-06 05:20:31332suffix.</p></div>
333<div class="para"><p>This document describes the currently defined hooks.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07334</div>
Junio C Hamanoba4b9282008-07-06 05:20:31335<h2 id="_applypatch_msg">applypatch-msg</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07336<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31337<div class="para"><p>This hook is invoked by <em>git-am</em> script. It takes a single
Junio C Hamano2fbcd212008-05-14 22:26:07338parameter, the name of the file that holds the proposed commit
339log message. Exiting with non-zero status causes
Junio C Hamanoba4b9282008-07-06 05:20:31340<em>git-am</em> to abort before applying the patch.</p></div>
341<div class="para"><p>The hook is allowed to edit the message file in place, and can
Junio C Hamano2fbcd212008-05-14 22:26:07342be used to normalize the message into some project standard
343format (if the project has one). It can also be used to refuse
Junio C Hamanoba4b9282008-07-06 05:20:31344the commit after inspecting the message file.</p></div>
345<div class="para"><p>The default <em>applypatch-msg</em> hook, when enabled, runs the
346<em>commit-msg</em> hook, if the latter is enabled.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07347</div>
Junio C Hamanoba4b9282008-07-06 05:20:31348<h2 id="_pre_applypatch">pre-applypatch</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07349<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31350<div class="para"><p>This hook is invoked by <em>git-am</em>. It takes no parameter, and is
351invoked after the patch is applied, but before a commit is made.</p></div>
352<div class="para"><p>If it exits with non-zero status, then the working tree will not be
353committed after applying the patch.</p></div>
354<div class="para"><p>It can be used to inspect the current working tree and refuse to
355make a commit if it does not pass certain test.</p></div>
356<div class="para"><p>The default <em>pre-applypatch</em> hook, when enabled, runs the
357<em>pre-commit</em> hook, if the latter is enabled.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07358</div>
Junio C Hamanoba4b9282008-07-06 05:20:31359<h2 id="_post_applypatch">post-applypatch</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07360<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31361<div class="para"><p>This hook is invoked by <em>git-am</em>. It takes no parameter,
362and is invoked after the patch is applied and a commit is made.</p></div>
363<div class="para"><p>This hook is meant primarily for notification, and cannot affect
364the outcome of <em>git-am</em>.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07365</div>
Junio C Hamanoba4b9282008-07-06 05:20:31366<h2 id="_pre_commit">pre-commit</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07367<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31368<div class="para"><p>This hook is invoked by <em>git-commit</em>, and can be bypassed
Junio C Hamano2fbcd212008-05-14 22:26:07369with <tt>--no-verify</tt> option. It takes no parameter, and is
370invoked before obtaining the proposed commit log message and
371making a commit. Exiting with non-zero status from this script
Junio C Hamanoba4b9282008-07-06 05:20:31372causes the <em>git-commit</em> to abort.</p></div>
373<div class="para"><p>The default <em>pre-commit</em> hook, when enabled, catches introduction
Junio C Hamano2fbcd212008-05-14 22:26:07374of lines with trailing whitespaces and aborts the commit when
Junio C Hamanoba4b9282008-07-06 05:20:31375such a line is found.</p></div>
376<div class="para"><p>All the <em>git-commit</em> hooks are invoked with the environment
Junio C Hamano2fbcd212008-05-14 22:26:07377variable <tt>GIT_EDITOR=:</tt> if the command will not bring up an editor
Junio C Hamanoba4b9282008-07-06 05:20:31378to modify the commit message.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07379</div>
Junio C Hamanoba4b9282008-07-06 05:20:31380<h2 id="_prepare_commit_msg">prepare-commit-msg</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07381<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31382<div class="para"><p>This hook is invoked by <em>git-commit</em> right after preparing the
383default log message, and before the editor is started.</p></div>
384<div class="para"><p>It takes one to three parameters. The first is the name of the file
Junio C Hamano2fbcd212008-05-14 22:26:07385that the commit log message. The second is the source of the commit
Junio C Hamanoa476efa2008-10-10 15:31:42386message, and can be: <tt>message</tt> (if a <tt>-m</tt> or <tt>-F</tt> option was
387given); <tt>template</tt> (if a <tt>-t</tt> option was given or the
Junio C Hamano2fbcd212008-05-14 22:26:07388configuration option <tt>commit.template</tt> is set); <tt>merge</tt> (if the
389commit is a merge or a <tt>.git/MERGE_MSG</tt> file exists); <tt>squash</tt>
390(if a <tt>.git/SQUASH_MSG</tt> file exists); or <tt>commit</tt>, followed by
Junio C Hamanoa476efa2008-10-10 15:31:42391a commit SHA1 (if a <tt>-c</tt>, <tt>-C</tt> or <tt>--amend</tt> option was given).</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31392<div class="para"><p>If the exit status is non-zero, <em>git-commit</em> will abort.</p></div>
393<div class="para"><p>The purpose of the hook is to edit the message file in place, and
Junio C Hamano2fbcd212008-05-14 22:26:07394it is not suppressed by the <tt>--no-verify</tt> option. A non-zero exit
395means a failure of the hook and aborts the commit. It should not
Junio C Hamanoba4b9282008-07-06 05:20:31396be used as replacement for pre-commit hook.</p></div>
397<div class="para"><p>The sample <tt>prepare-commit-msg</tt> hook that comes with git comments
398out the <tt>Conflicts:</tt> part of a merge's commit message.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07399</div>
Junio C Hamanoba4b9282008-07-06 05:20:31400<h2 id="_commit_msg">commit-msg</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07401<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31402<div class="para"><p>This hook is invoked by <em>git-commit</em>, and can be bypassed
Junio C Hamano2fbcd212008-05-14 22:26:07403with <tt>--no-verify</tt> option. It takes a single parameter, the
404name of the file that holds the proposed commit log message.
Junio C Hamanoba4b9282008-07-06 05:20:31405Exiting with non-zero status causes the <em>git-commit</em> to
406abort.</p></div>
407<div class="para"><p>The hook is allowed to edit the message file in place, and can
Junio C Hamano2fbcd212008-05-14 22:26:07408be used to normalize the message into some project standard
409format (if the project has one). It can also be used to refuse
Junio C Hamanoba4b9282008-07-06 05:20:31410the commit after inspecting the message file.</p></div>
411<div class="para"><p>The default <em>commit-msg</em> hook, when enabled, detects duplicate
412"Signed-off-by" lines, and aborts the commit if one is found.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07413</div>
Junio C Hamanoba4b9282008-07-06 05:20:31414<h2 id="_post_commit">post-commit</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07415<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31416<div class="para"><p>This hook is invoked by <em>git-commit</em>. It takes no
417parameter, and is invoked after a commit is made.</p></div>
418<div class="para"><p>This hook is meant primarily for notification, and cannot affect
419the outcome of <em>git-commit</em>.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07420</div>
Junio C Hamanoa476efa2008-10-10 15:31:42421<h2 id="_pre_rebase">pre-rebase</h2>
422<div class="sectionbody">
423<div class="para"><p>This hook is called by <em>git-rebase</em> and can be used to prevent a branch
424from getting rebased.</p></div>
425</div>
Junio C Hamanoba4b9282008-07-06 05:20:31426<h2 id="_post_checkout">post-checkout</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07427<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31428<div class="para"><p>This hook is invoked when a <em>git-checkout</em> is run after having updated the
Junio C Hamano2fbcd212008-05-14 22:26:07429worktree. The hook is given three parameters: the ref of the previous HEAD,
430the ref of the new HEAD (which may or may not have changed), and a flag
431indicating whether the checkout was a branch checkout (changing branches,
432flag=1) or a file checkout (retrieving a file from the index, flag=0).
Junio C Hamanoba4b9282008-07-06 05:20:31433This hook cannot affect the outcome of <em>git-checkout</em>.</p></div>
434<div class="para"><p>This hook can be used to perform repository validity checks, auto-display
Junio C Hamano2fbcd212008-05-14 22:26:07435differences from the previous HEAD if different, or set working dir metadata
Junio C Hamanoba4b9282008-07-06 05:20:31436properties.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07437</div>
Junio C Hamanoba4b9282008-07-06 05:20:31438<h2 id="_post_merge">post-merge</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07439<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31440<div class="para"><p>This hook is invoked by <em>git-merge</em>, which happens when a <em>git-pull</em>
Junio C Hamano2fbcd212008-05-14 22:26:07441is done on a local repository. The hook takes a single parameter, a status
442flag specifying whether or not the merge being done was a squash merge.
Junio C Hamanoba4b9282008-07-06 05:20:31443This hook cannot affect the outcome of <em>git-merge</em> and is not executed,
444if the merge failed due to conflicts.</p></div>
445<div class="para"><p>This hook can be used in conjunction with a corresponding pre-commit hook to
Junio C Hamano2fbcd212008-05-14 22:26:07446save and restore any form of metadata associated with the working tree
447(eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl
Junio C Hamanoba4b9282008-07-06 05:20:31448for an example of how to do this.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07449</div>
Junio C Hamanoba4b9282008-07-06 05:20:31450<h2 id="pre-receive">pre-receive</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07451<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31452<div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
453which happens when a <em>git-push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07454Just before starting to update refs on the remote repository, the
455pre-receive hook is invoked. Its exit status determines the success
Junio C Hamanoba4b9282008-07-06 05:20:31456or failure of the update.</p></div>
457<div class="para"><p>This hook executes once for the receive operation. It takes no
Junio C Hamano2fbcd212008-05-14 22:26:07458arguments, but for each ref to be updated it receives on standard
Junio C Hamanoba4b9282008-07-06 05:20:31459input a line of the format:</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07460<div class="literalblock">
461<div class="content">
462<pre><tt>&lt;old-value&gt; SP &lt;new-value&gt; SP &lt;ref-name&gt; LF</tt></pre>
463</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31464<div class="para"><p>where <tt>&lt;old-value&gt;</tt> is the old object name stored in the ref,
Junio C Hamano2fbcd212008-05-14 22:26:07465<tt>&lt;new-value&gt;</tt> is the new object name to be stored in the ref and
466<tt>&lt;ref-name&gt;</tt> is the full name of the ref.
Junio C Hamanoba4b9282008-07-06 05:20:31467When creating a new ref, <tt>&lt;old-value&gt;</tt> is 40 <tt>0</tt>.</p></div>
468<div class="para"><p>If the hook exits with non-zero status, none of the refs will be
Junio C Hamano2fbcd212008-05-14 22:26:07469updated. If the hook exits with zero, updating of individual refs can
Junio C Hamanoba4b9282008-07-06 05:20:31470still be prevented by the <a href="#update"><em>update</em></a> hook.</p></div>
471<div class="para"><p>Both standard output and standard error output are forwarded to
472<em>git-send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
473for the user.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07474</div>
Junio C Hamanoba4b9282008-07-06 05:20:31475<h2 id="update">update</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07476<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31477<div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
478which happens when a <em>git-push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07479Just before updating the ref on the remote repository, the update hook
480is invoked. Its exit status determines the success or failure of
Junio C Hamanoba4b9282008-07-06 05:20:31481the ref update.</p></div>
482<div class="para"><p>The hook executes once for each ref to be updated, and takes
483three parameters:</p></div>
484<div class="ilist"><ul>
Junio C Hamano2fbcd212008-05-14 22:26:07485<li>
486<p>
487the name of the ref being updated,
488</p>
489</li>
490<li>
491<p>
492the old object name stored in the ref,
493</p>
494</li>
495<li>
496<p>
497and the new objectname to be stored in the ref.
498</p>
499</li>
Junio C Hamanoba4b9282008-07-06 05:20:31500</ul></div>
501<div class="para"><p>A zero exit from the update hook allows the ref to be updated.
502Exiting with a non-zero status prevents <em>git-receive-pack</em>
503from updating that ref.</p></div>
504<div class="para"><p>This hook can be used to prevent <em>forced</em> update on certain refs by
Junio C Hamano2fbcd212008-05-14 22:26:07505making sure that the object name is a commit object that is a
506descendant of the commit object named by the old object name.
Junio C Hamanoba4b9282008-07-06 05:20:31507That is, to enforce a "fast forward only" policy.</p></div>
508<div class="para"><p>It could also be used to log the old..new status. However, it
Junio C Hamano2fbcd212008-05-14 22:26:07509does not know the entire set of branches, so it would end up
510firing one e-mail per ref when used naively, though. The
Junio C Hamanoba4b9282008-07-06 05:20:31511<a href="#post-receive"><em>post-receive</em></a> hook is more suited to that.</p></div>
512<div class="para"><p>Another use suggested on the mailing list is to use this hook to
Junio C Hamano2fbcd212008-05-14 22:26:07513implement access control which is finer grained than the one
Junio C Hamanoba4b9282008-07-06 05:20:31514based on filesystem group.</p></div>
515<div class="para"><p>Both standard output and standard error output are forwarded to
516<em>git-send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
517for the user.</p></div>
518<div class="para"><p>The default <em>update</em> hook, when enabled--and with
Junio C Hamano2fbcd212008-05-14 22:26:07519<tt>hooks.allowunannotated</tt> config option turned on--prevents
Junio C Hamanoba4b9282008-07-06 05:20:31520unannotated tags to be pushed.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07521</div>
Junio C Hamanoba4b9282008-07-06 05:20:31522<h2 id="post-receive">post-receive</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07523<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31524<div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
525which happens when a <em>git-push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07526It executes on the remote repository once after all the refs have
Junio C Hamanoba4b9282008-07-06 05:20:31527been updated.</p></div>
528<div class="para"><p>This hook executes once for the receive operation. It takes no
Junio C Hamano2fbcd212008-05-14 22:26:07529arguments, but gets the same information as the
530<a href="#pre-receive"><em>pre-receive</em></a>
Junio C Hamanoba4b9282008-07-06 05:20:31531hook does on its standard input.</p></div>
532<div class="para"><p>This hook does not affect the outcome of <em>git-receive-pack</em>, as it
533is called after the real work is done.</p></div>
534<div class="para"><p>This supersedes the <a href="#post-update"><em>post-update</em></a> hook in that it gets
Junio C Hamano2fbcd212008-05-14 22:26:07535both old and new values of all the refs in addition to their
Junio C Hamanoba4b9282008-07-06 05:20:31536names.</p></div>
537<div class="para"><p>Both standard output and standard error output are forwarded to
538<em>git-send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
539for the user.</p></div>
540<div class="para"><p>The default <em>post-receive</em> hook is empty, but there is
Junio C Hamano2fbcd212008-05-14 22:26:07541a sample script <tt>post-receive-email</tt> provided in the <tt>contrib/hooks</tt>
542directory in git distribution, which implements sending commit
Junio C Hamanoba4b9282008-07-06 05:20:31543emails.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07544</div>
Junio C Hamanoba4b9282008-07-06 05:20:31545<h2 id="post-update">post-update</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07546<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31547<div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
548which happens when a <em>git-push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07549It executes on the remote repository once after all the refs have
Junio C Hamanoba4b9282008-07-06 05:20:31550been updated.</p></div>
551<div class="para"><p>It takes a variable number of parameters, each of which is the
552name of ref that was actually updated.</p></div>
553<div class="para"><p>This hook is meant primarily for notification, and cannot affect
554the outcome of <em>git-receive-pack</em>.</p></div>
555<div class="para"><p>The <em>post-update</em> hook can tell what are the heads that were pushed,
Junio C Hamano2fbcd212008-05-14 22:26:07556but it does not know what their original and updated values are,
557so it is a poor place to do log old..new. The
558<a href="#post-receive"><em>post-receive</em></a> hook does get both original and
559updated values of the refs. You might consider it instead if you need
Junio C Hamanoba4b9282008-07-06 05:20:31560them.</p></div>
561<div class="para"><p>When enabled, the default <em>post-update</em> hook runs
562<em>git-update-server-info</em> to keep the information used by dumb
Junio C Hamano2fbcd212008-05-14 22:26:07563transports (e.g., HTTP) up-to-date. If you are publishing
564a git repository that is accessible via HTTP, you should
Junio C Hamanoba4b9282008-07-06 05:20:31565probably enable this hook.</p></div>
566<div class="para"><p>Both standard output and standard error output are forwarded to
567<em>git-send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
568for the user.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07569</div>
Junio C Hamanoba4b9282008-07-06 05:20:31570<h2 id="_pre_auto_gc">pre-auto-gc</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07571<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31572<div class="para"><p>This hook is invoked by <em>git-gc --auto</em>. It takes no parameter, and
573exiting with non-zero status from this script causes the <em>git-gc --auto</em>
574to abort.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07575</div>
Junio C Hamanoba4b9282008-07-06 05:20:31576<h2 id="_git">GIT</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07577<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31578<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07579</div>
580<div id="footer">
581<div id="footer-text">
Junio C Hamanoa476efa2008-10-10 15:31:42582Last updated 2008-10-10 15:30:52 UTC
Junio C Hamano2fbcd212008-05-14 22:26:07583</div>
584</div>
585</body>
586</html>