blob: 100c050579d962758f979a5b8e154e3870ad9c2a [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 Hamano1aa40d22010-01-21 17:46:43329<em>git init</em> is run, a handful of example hooks are copied into 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>
Junio C Hamano8a48fa22008-12-18 08:44:30333<div class="admonitionblock">
334<table><tr>
335<td class="icon">
336<div class="title">Note</div>
337</td>
338<td class="content">It is also a requirement for a given hook to be executable.
339However - in a freshly initialized repository - the <tt>.sample</tt> files are
340executable by default.</td>
341</tr></table>
342</div>
Junio C Hamanoba4b9282008-07-06 05:20:31343<div class="para"><p>This document describes the currently defined hooks.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07344</div>
Junio C Hamanoc28068f2009-09-08 00:55:23345<h2 id="_hooks">HOOKS</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07346<div class="sectionbody">
Junio C Hamanoc28068f2009-09-08 00:55:23347<h3 id="_applypatch_msg">applypatch-msg</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43348<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:07349parameter, the name of the file that holds the proposed commit
350log message. Exiting with non-zero status causes
Junio C Hamano1aa40d22010-01-21 17:46:43351<em>git am</em> to abort before applying the patch.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31352<div class="para"><p>The hook is allowed to edit the message file in place, and can
Junio C Hamano2fbcd212008-05-14 22:26:07353be used to normalize the message into some project standard
354format (if the project has one). It can also be used to refuse
Junio C Hamanoba4b9282008-07-06 05:20:31355the commit after inspecting the message file.</p></div>
356<div class="para"><p>The default <em>applypatch-msg</em> hook, when enabled, runs the
357<em>commit-msg</em> hook, if the latter is enabled.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23358<h3 id="_pre_applypatch">pre-applypatch</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43359<div class="para"><p>This hook is invoked by <em>git am</em>. It takes no parameter, and is
Junio C Hamanoba4b9282008-07-06 05:20:31360invoked after the patch is applied, but before a commit is made.</p></div>
361<div class="para"><p>If it exits with non-zero status, then the working tree will not be
362committed after applying the patch.</p></div>
363<div class="para"><p>It can be used to inspect the current working tree and refuse to
364make a commit if it does not pass certain test.</p></div>
365<div class="para"><p>The default <em>pre-applypatch</em> hook, when enabled, runs the
366<em>pre-commit</em> hook, if the latter is enabled.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23367<h3 id="_post_applypatch">post-applypatch</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43368<div class="para"><p>This hook is invoked by <em>git am</em>. It takes no parameter,
Junio C Hamanoba4b9282008-07-06 05:20:31369and is invoked after the patch is applied and a commit is made.</p></div>
370<div class="para"><p>This hook is meant primarily for notification, and cannot affect
Junio C Hamano1aa40d22010-01-21 17:46:43371the outcome of <em>git am</em>.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23372<h3 id="_pre_commit">pre-commit</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43373<div class="para"><p>This hook is invoked by <em>git commit</em>, and can be bypassed
Junio C Hamano2fbcd212008-05-14 22:26:07374with <tt>--no-verify</tt> option. It takes no parameter, and is
375invoked before obtaining the proposed commit log message and
376making a commit. Exiting with non-zero status from this script
Junio C Hamano1aa40d22010-01-21 17:46:43377causes the <em>git commit</em> to abort.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31378<div class="para"><p>The default <em>pre-commit</em> hook, when enabled, catches introduction
Junio C Hamano2fbcd212008-05-14 22:26:07379of lines with trailing whitespaces and aborts the commit when
Junio C Hamanoba4b9282008-07-06 05:20:31380such a line is found.</p></div>
Junio C Hamano1aa40d22010-01-21 17:46:43381<div class="para"><p>All the <em>git commit</em> hooks are invoked with the environment
Junio C Hamano2fbcd212008-05-14 22:26:07382variable <tt>GIT_EDITOR=:</tt> if the command will not bring up an editor
Junio C Hamanoba4b9282008-07-06 05:20:31383to modify the commit message.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23384<h3 id="_prepare_commit_msg">prepare-commit-msg</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43385<div class="para"><p>This hook is invoked by <em>git commit</em> right after preparing the
Junio C Hamanoba4b9282008-07-06 05:20:31386default log message, and before the editor is started.</p></div>
387<div class="para"><p>It takes one to three parameters. The first is the name of the file
Junio C Hamanobd53dbf2009-01-18 18:26:37388that contains the commit log message. The second is the source of the commit
Junio C Hamanoa476efa2008-10-10 15:31:42389message, and can be: <tt>message</tt> (if a <tt>-m</tt> or <tt>-F</tt> option was
390given); <tt>template</tt> (if a <tt>-t</tt> option was given or the
Junio C Hamano2fbcd212008-05-14 22:26:07391configuration option <tt>commit.template</tt> is set); <tt>merge</tt> (if the
392commit is a merge or a <tt>.git/MERGE_MSG</tt> file exists); <tt>squash</tt>
393(if a <tt>.git/SQUASH_MSG</tt> file exists); or <tt>commit</tt>, followed by
Junio C Hamanoa476efa2008-10-10 15:31:42394a commit SHA1 (if a <tt>-c</tt>, <tt>-C</tt> or <tt>--amend</tt> option was given).</p></div>
Junio C Hamano1aa40d22010-01-21 17:46:43395<div class="para"><p>If the exit status is non-zero, <em>git commit</em> will abort.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31396<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:07397it is not suppressed by the <tt>--no-verify</tt> option. A non-zero exit
398means a failure of the hook and aborts the commit. It should not
Junio C Hamanoba4b9282008-07-06 05:20:31399be used as replacement for pre-commit hook.</p></div>
400<div class="para"><p>The sample <tt>prepare-commit-msg</tt> hook that comes with git comments
401out the <tt>Conflicts:</tt> part of a merge's commit message.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23402<h3 id="_commit_msg">commit-msg</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43403<div class="para"><p>This hook is invoked by <em>git commit</em>, and can be bypassed
Junio C Hamano2fbcd212008-05-14 22:26:07404with <tt>--no-verify</tt> option. It takes a single parameter, the
405name of the file that holds the proposed commit log message.
Junio C Hamano1aa40d22010-01-21 17:46:43406Exiting with non-zero status causes the <em>git commit</em> to
Junio C Hamanoba4b9282008-07-06 05:20:31407abort.</p></div>
408<div class="para"><p>The hook is allowed to edit the message file in place, and can
Junio C Hamano2fbcd212008-05-14 22:26:07409be used to normalize the message into some project standard
410format (if the project has one). It can also be used to refuse
Junio C Hamanoba4b9282008-07-06 05:20:31411the commit after inspecting the message file.</p></div>
412<div class="para"><p>The default <em>commit-msg</em> hook, when enabled, detects duplicate
413"Signed-off-by" lines, and aborts the commit if one is found.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23414<h3 id="_post_commit">post-commit</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43415<div class="para"><p>This hook is invoked by <em>git commit</em>. It takes no
Junio C Hamanoba4b9282008-07-06 05:20:31416parameter, and is invoked after a commit is made.</p></div>
417<div class="para"><p>This hook is meant primarily for notification, and cannot affect
Junio C Hamano1aa40d22010-01-21 17:46:43418the outcome of <em>git commit</em>.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23419<h3 id="_pre_rebase">pre-rebase</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43420<div class="para"><p>This hook is called by <em>git rebase</em> and can be used to prevent a branch
Junio C Hamanoa476efa2008-10-10 15:31:42421from getting rebased.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23422<h3 id="_post_checkout">post-checkout</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43423<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:07424worktree. The hook is given three parameters: the ref of the previous HEAD,
425the ref of the new HEAD (which may or may not have changed), and a flag
426indicating whether the checkout was a branch checkout (changing branches,
427flag=1) or a file checkout (retrieving a file from the index, flag=0).
Junio C Hamano1aa40d22010-01-21 17:46:43428This hook cannot affect the outcome of <em>git checkout</em>.</p></div>
429<div class="para"><p>It is also run after <em>git clone</em>, unless the --no-checkout (-n) option is
Junio C Hamano36a56722009-03-28 08:55:34430used. The first parameter given to the hook is the null-ref, the second the
431ref of the new HEAD and the flag is always 1.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31432<div class="para"><p>This hook can be used to perform repository validity checks, auto-display
Junio C Hamano2fbcd212008-05-14 22:26:07433differences from the previous HEAD if different, or set working dir metadata
Junio C Hamanoba4b9282008-07-06 05:20:31434properties.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23435<h3 id="_post_merge">post-merge</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43436<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:07437is done on a local repository. The hook takes a single parameter, a status
438flag specifying whether or not the merge being done was a squash merge.
Junio C Hamano1aa40d22010-01-21 17:46:43439This hook cannot affect the outcome of <em>git merge</em> and is not executed,
Junio C Hamanoba4b9282008-07-06 05:20:31440if the merge failed due to conflicts.</p></div>
441<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:07442save and restore any form of metadata associated with the working tree
443(eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl
Junio C Hamanoba4b9282008-07-06 05:20:31444for an example of how to do this.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23445<h3 id="pre-receive">pre-receive</h3><div style="clear:left"></div>
Junio C Hamanoba4b9282008-07-06 05:20:31446<div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
Junio C Hamano1aa40d22010-01-21 17:46:43447which happens when a <em>git push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07448Just before starting to update refs on the remote repository, the
449pre-receive hook is invoked. Its exit status determines the success
Junio C Hamanoba4b9282008-07-06 05:20:31450or failure of the update.</p></div>
451<div class="para"><p>This hook executes once for the receive operation. It takes no
Junio C Hamano2fbcd212008-05-14 22:26:07452arguments, but for each ref to be updated it receives on standard
Junio C Hamanoba4b9282008-07-06 05:20:31453input a line of the format:</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07454<div class="literalblock">
455<div class="content">
456<pre><tt>&lt;old-value&gt; SP &lt;new-value&gt; SP &lt;ref-name&gt; LF</tt></pre>
457</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31458<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:07459<tt>&lt;new-value&gt;</tt> is the new object name to be stored in the ref and
460<tt>&lt;ref-name&gt;</tt> is the full name of the ref.
Junio C Hamanoba4b9282008-07-06 05:20:31461When creating a new ref, <tt>&lt;old-value&gt;</tt> is 40 <tt>0</tt>.</p></div>
462<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:07463updated. If the hook exits with zero, updating of individual refs can
Junio C Hamanoba4b9282008-07-06 05:20:31464still be prevented by the <a href="#update"><em>update</em></a> hook.</p></div>
465<div class="para"><p>Both standard output and standard error output are forwarded to
Junio C Hamano1aa40d22010-01-21 17:46:43466<em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
Junio C Hamanoba4b9282008-07-06 05:20:31467for the user.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23468<h3 id="update">update</h3><div style="clear:left"></div>
Junio C Hamanoba4b9282008-07-06 05:20:31469<div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
Junio C Hamano1aa40d22010-01-21 17:46:43470which happens when a <em>git push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07471Just before updating the ref on the remote repository, the update hook
472is invoked. Its exit status determines the success or failure of
Junio C Hamanoba4b9282008-07-06 05:20:31473the ref update.</p></div>
474<div class="para"><p>The hook executes once for each ref to be updated, and takes
475three parameters:</p></div>
476<div class="ilist"><ul>
Junio C Hamano2fbcd212008-05-14 22:26:07477<li>
478<p>
479the name of the ref being updated,
480</p>
481</li>
482<li>
483<p>
484the old object name stored in the ref,
485</p>
486</li>
487<li>
488<p>
489and the new objectname to be stored in the ref.
490</p>
491</li>
Junio C Hamanoba4b9282008-07-06 05:20:31492</ul></div>
493<div class="para"><p>A zero exit from the update hook allows the ref to be updated.
494Exiting with a non-zero status prevents <em>git-receive-pack</em>
495from updating that ref.</p></div>
496<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:07497making sure that the object name is a commit object that is a
498descendant of the commit object named by the old object name.
Junio C Hamano3f680f32009-11-16 02:10:54499That is, to enforce a "fast-forward only" policy.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31500<div class="para"><p>It could also be used to log the old..new status. However, it
Junio C Hamano2fbcd212008-05-14 22:26:07501does not know the entire set of branches, so it would end up
502firing one e-mail per ref when used naively, though. The
Junio C Hamanoba4b9282008-07-06 05:20:31503<a href="#post-receive"><em>post-receive</em></a> hook is more suited to that.</p></div>
504<div class="para"><p>Another use suggested on the mailing list is to use this hook to
Junio C Hamano2fbcd212008-05-14 22:26:07505implement access control which is finer grained than the one
Junio C Hamanoba4b9282008-07-06 05:20:31506based on filesystem group.</p></div>
507<div class="para"><p>Both standard output and standard error output are forwarded to
Junio C Hamano1aa40d22010-01-21 17:46:43508<em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
Junio C Hamanoba4b9282008-07-06 05:20:31509for the user.</p></div>
510<div class="para"><p>The default <em>update</em> hook, when enabled--and with
Junio C Hamanod6fff402009-09-14 09:40:50511<tt>hooks.allowunannotated</tt> config option unset or set to false--prevents
Junio C Hamanoba4b9282008-07-06 05:20:31512unannotated tags to be pushed.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23513<h3 id="post-receive">post-receive</h3><div style="clear:left"></div>
Junio C Hamanoba4b9282008-07-06 05:20:31514<div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
Junio C Hamano1aa40d22010-01-21 17:46:43515which happens when a <em>git push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07516It executes on the remote repository once after all the refs have
Junio C Hamanoba4b9282008-07-06 05:20:31517been updated.</p></div>
518<div class="para"><p>This hook executes once for the receive operation. It takes no
Junio C Hamano2fbcd212008-05-14 22:26:07519arguments, but gets the same information as the
520<a href="#pre-receive"><em>pre-receive</em></a>
Junio C Hamanoba4b9282008-07-06 05:20:31521hook does on its standard input.</p></div>
522<div class="para"><p>This hook does not affect the outcome of <em>git-receive-pack</em>, as it
523is called after the real work is done.</p></div>
524<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:07525both old and new values of all the refs in addition to their
Junio C Hamanoba4b9282008-07-06 05:20:31526names.</p></div>
527<div class="para"><p>Both standard output and standard error output are forwarded to
Junio C Hamano1aa40d22010-01-21 17:46:43528<em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
Junio C Hamanoba4b9282008-07-06 05:20:31529for the user.</p></div>
530<div class="para"><p>The default <em>post-receive</em> hook is empty, but there is
Junio C Hamano2fbcd212008-05-14 22:26:07531a sample script <tt>post-receive-email</tt> provided in the <tt>contrib/hooks</tt>
532directory in git distribution, which implements sending commit
Junio C Hamanoba4b9282008-07-06 05:20:31533emails.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23534<h3 id="post-update">post-update</h3><div style="clear:left"></div>
Junio C Hamanoba4b9282008-07-06 05:20:31535<div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
Junio C Hamano1aa40d22010-01-21 17:46:43536which happens when a <em>git push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07537It executes on the remote repository once after all the refs have
Junio C Hamanoba4b9282008-07-06 05:20:31538been updated.</p></div>
539<div class="para"><p>It takes a variable number of parameters, each of which is the
540name of ref that was actually updated.</p></div>
541<div class="para"><p>This hook is meant primarily for notification, and cannot affect
542the outcome of <em>git-receive-pack</em>.</p></div>
543<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:07544but it does not know what their original and updated values are,
545so it is a poor place to do log old..new. The
546<a href="#post-receive"><em>post-receive</em></a> hook does get both original and
547updated values of the refs. You might consider it instead if you need
Junio C Hamanoba4b9282008-07-06 05:20:31548them.</p></div>
549<div class="para"><p>When enabled, the default <em>post-update</em> hook runs
Junio C Hamano1aa40d22010-01-21 17:46:43550<em>git update-server-info</em> to keep the information used by dumb
Junio C Hamano2fbcd212008-05-14 22:26:07551transports (e.g., HTTP) up-to-date. If you are publishing
552a git repository that is accessible via HTTP, you should
Junio C Hamanoba4b9282008-07-06 05:20:31553probably enable this hook.</p></div>
554<div class="para"><p>Both standard output and standard error output are forwarded to
Junio C Hamano1aa40d22010-01-21 17:46:43555<em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
Junio C Hamanoba4b9282008-07-06 05:20:31556for the user.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23557<h3 id="_pre_auto_gc">pre-auto-gc</h3><div style="clear:left"></div>
Junio C Hamano1aa40d22010-01-21 17:46:43558<div class="para"><p>This hook is invoked by <em>git gc --auto</em>. It takes no parameter, and
559exiting with non-zero status from this script causes the <em>git gc --auto</em>
Junio C Hamanoba4b9282008-07-06 05:20:31560to abort.</p></div>
Junio C Hamano31667362010-03-25 00:38:53561<h3 id="_post_rewrite">post-rewrite</h3><div style="clear:left"></div>
562<div class="para"><p>This hook is invoked by commands that rewrite commits (<tt>git commit
563--amend</tt>, <em>git-rebase</em>; currently <em>git-filter-branch</em> does <em>not</em> call
564it!). Its first argument denotes the command it was invoked by:
565currently one of <tt>amend</tt> or <tt>rebase</tt>. Further command-dependent
566arguments may be passed in the future.</p></div>
567<div class="para"><p>The hook receives a list of the rewritten commits on stdin, in the
568format</p></div>
569<div class="literalblock">
570<div class="content">
571<pre><tt>&lt;old-sha1&gt; SP &lt;new-sha1&gt; [ SP &lt;extra-info&gt; ] LF</tt></pre>
572</div></div>
573<div class="para"><p>The <em>extra-info</em> is again command-dependent. If it is empty, the
574preceding SP is also omitted. Currently, no commands pass any
575<em>extra-info</em>.</p></div>
576<div class="para"><p>The hook always runs after the automatic note copying (see
577"notes.rewrite.&lt;command&gt;" in linkgit:git-config.txt) has happened, and
578thus has access to these notes.</p></div>
579<div class="para"><p>The following command-specific comments apply:</p></div>
580<div class="vlist"><dl>
581<dt>
582rebase
583</dt>
584<dd>
585<p>
586 For the <em>squash</em> and <em>fixup</em> operation, all commits that were
587 squashed are listed as being rewritten to the squashed commit.
588 This means that there will be several lines sharing the same
589 <em>new-sha1</em>.
590</p>
591<div class="para"><p>The commits are guaranteed to be listed in the order that they were
592processed by rebase.</p></div>
593</dd>
594</dl></div>
595<div class="para"><p>There is no default <em>post-rewrite</em> hook, but see the
596<tt>post-receive-copy-notes</tt> script in <tt>contrib/hooks</tt> for an example
597that copies your git-notes to the rewritten commits.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07598</div>
Junio C Hamanoba4b9282008-07-06 05:20:31599<h2 id="_git">GIT</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07600<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31601<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07602</div>
603<div id="footer">
604<div id="footer-text">
Junio C Hamano08acb732010-07-21 21:58:33605Last updated 2010-07-21 21:55:42 UTC
Junio C Hamano2fbcd212008-05-14 22:26:07606</div>
607</div>
608</body>
609</html>