blob: 87964697fa0595fbdc87baf8d05ad29c3988857b [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 Hamano81435632011-01-12 09:08:486<meta name="generator" content="AsciiDoc 8.4.5" />
7<title>githooks(5)</title>
Junio C Hamano2fbcd212008-05-14 22:26:078<style type="text/css">
9/* Debug borders */
10p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11/*
12 border: 1px solid red;
13*/
14}
15
16body {
17 margin: 1em 5% 1em 5%;
18}
19
Junio C Hamanoba4b9282008-07-06 05:20:3120a {
21 color: blue;
22 text-decoration: underline;
23}
24a:visited {
25 color: fuchsia;
26}
Junio C Hamano2fbcd212008-05-14 22:26:0727
28em {
29 font-style: italic;
Junio C Hamano81435632011-01-12 09:08:4830 color: navy;
Junio C Hamano2fbcd212008-05-14 22:26:0731}
32
33strong {
34 font-weight: bold;
Junio C Hamano81435632011-01-12 09:08:4835 color: #083194;
Junio C Hamano2fbcd212008-05-14 22:26:0736}
37
38tt {
39 color: navy;
40}
41
42h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
48}
49
Junio C Hamanoba4b9282008-07-06 05:20:3150h1, h2, h3 {
Junio C Hamano2fbcd212008-05-14 22:26:0751 border-bottom: 2px solid silver;
52}
53h2 {
Junio C Hamano2fbcd212008-05-14 22:26:0754 padding-top: 0.5em;
55}
Junio C Hamanoba4b9282008-07-06 05:20:3156h3 {
57 float: left;
58}
59h3 + * {
60 clear: left;
61}
Junio C Hamano2fbcd212008-05-14 22:26:0762
63div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
66}
67
68hr {
69 border: 1px solid silver;
70}
71
72p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
75}
76
Junio C Hamano81435632011-01-12 09:08:4877ul, ol, li > p {
78 margin-top: 0;
79}
80
Junio C Hamano2fbcd212008-05-14 22:26:0781pre {
82 padding: 0;
83 margin: 0;
84}
85
86span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3190 font-size: 1.1em;
Junio C Hamano2fbcd212008-05-14 22:26:0791}
92span#email {
93}
Junio C Hamano81435632011-01-12 09:08:4894span#revnumber, span#revdate, span#revremark {
Junio C Hamano2fbcd212008-05-14 22:26:0795 font-family: sans-serif;
96}
97
98div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
104}
105div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
108}
109div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
112}
113
Junio C Hamano81435632011-01-12 09:08:48114div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
117}
Junio C Hamano2fbcd212008-05-14 22:26:07118div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120div.admonitionblock {
Junio C Hamano2fbcd212008-05-14 22:26:07121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
123}
124div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
127}
128
129div.content { /* Block element content. */
130 padding: 0;
131}
132
133/* Block element titles. */
134div.title, caption.title {
Junio C Hamano81435632011-01-12 09:08:48135 color: #527bbd;
Junio C Hamano2fbcd212008-05-14 22:26:07136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
141}
142div.title + * {
143 margin-top: 0;
144}
145
146td div.title:first-child {
147 margin-top: 0.0em;
148}
149div.content div.title:first-child {
150 margin-top: 0.0em;
151}
152div.content + div.title {
153 margin-top: 0.0em;
154}
155
156div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
160}
161
162div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
166}
167
Junio C Hamano81435632011-01-12 09:08:48168div.quoteblock {
Junio C Hamano2fbcd212008-05-14 22:26:07169 padding-left: 2.0em;
Junio C Hamano81435632011-01-12 09:08:48170 margin-right: 10%;
Junio C Hamano2fbcd212008-05-14 22:26:07171}
Junio C Hamano81435632011-01-12 09:08:48172div.quoteblock > div.attribution {
173 padding-top: 0.5em;
Junio C Hamano2fbcd212008-05-14 22:26:07174 text-align: right;
175}
Junio C Hamano81435632011-01-12 09:08:48176
177div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
180}
181div.verseblock > div.content {
182 white-space: pre;
183}
184div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
187}
188/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
Junio C Hamanoba4b9282008-07-06 05:20:31189div.verseblock + div.attribution {
190 text-align: left;
191}
Junio C Hamano2fbcd212008-05-14 22:26:07192
193div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
200}
201div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
204}
205
206div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
209}
210
Junio C Hamano2fbcd212008-05-14 22:26:07211div.imageblock div.content { padding-left: 0; }
Junio C Hamano2fbcd212008-05-14 22:26:07212span.image img { border-style: none; }
Junio C Hamano81435632011-01-12 09:08:48213a.image:visited { color: white; }
Junio C Hamano2fbcd212008-05-14 22:26:07214
215dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
218}
219dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
Junio C Hamano81435632011-01-12 09:08:48222 font-style: normal;
223 color: navy;
Junio C Hamano2fbcd212008-05-14 22:26:07224}
225dd > *:first-child {
Junio C Hamano81435632011-01-12 09:08:48226 margin-top: 0.1em;
Junio C Hamano2fbcd212008-05-14 22:26:07227}
228
229ul, ol {
230 list-style-position: outside;
231}
Junio C Hamano81435632011-01-12 09:08:48232ol.arabic {
233 list-style-type: decimal;
234}
235ol.loweralpha {
Junio C Hamano2fbcd212008-05-14 22:26:07236 list-style-type: lower-alpha;
237}
Junio C Hamano81435632011-01-12 09:08:48238ol.upperalpha {
239 list-style-type: upper-alpha;
240}
241ol.lowerroman {
242 list-style-type: lower-roman;
243}
244ol.upperroman {
245 list-style-type: upper-roman;
246}
247
248div.compact ul, div.compact ol,
249div.compact p, div.compact p,
250div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
253}
Junio C Hamano2fbcd212008-05-14 22:26:07254
255div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31256 border: 3px solid #527bbd;
Junio C Hamano2fbcd212008-05-14 22:26:07257}
258thead {
259 font-family: sans-serif;
260 font-weight: bold;
261}
262tfoot {
263 font-weight: bold;
264}
Junio C Hamano81435632011-01-12 09:08:48265td > div.verse {
266 white-space: pre;
267}
268p.table {
269 margin-top: 0;
270}
271/* Because the table frame attribute is overriden by CSS in most browsers. */
272div.tableblock > table[frame="void"] {
273 border-style: none;
274}
275div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
278}
279div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
282}
Junio C Hamano2fbcd212008-05-14 22:26:07283
Junio C Hamano81435632011-01-12 09:08:48284
285div.hdlist {
Junio C Hamano2fbcd212008-05-14 22:26:07286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
288}
Junio C Hamano81435632011-01-12 09:08:48289div.hdlist tr {
290 padding-bottom: 15px;
Junio C Hamanoba4b9282008-07-06 05:20:31291}
Junio C Hamano81435632011-01-12 09:08:48292dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
294}
295td.hdlist1 {
Junio C Hamano2fbcd212008-05-14 22:26:07296 vertical-align: top;
Junio C Hamano81435632011-01-12 09:08:48297 font-style: normal;
Junio C Hamano2fbcd212008-05-14 22:26:07298 padding-right: 0.8em;
Junio C Hamano81435632011-01-12 09:08:48299 color: navy;
Junio C Hamano2fbcd212008-05-14 22:26:07300}
Junio C Hamano81435632011-01-12 09:08:48301td.hdlist2 {
Junio C Hamano2fbcd212008-05-14 22:26:07302 vertical-align: top;
303}
Junio C Hamano81435632011-01-12 09:08:48304div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
307}
308
309.comment {
310 background: yellow;
311}
Junio C Hamano2fbcd212008-05-14 22:26:07312
313@media print {
314 div#footer-badges { display: none; }
315}
Junio C Hamanoba4b9282008-07-06 05:20:31316
317div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
324}
325
326div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
329}
330div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
333}
334div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
337}
338div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
341}
Junio C Hamano81435632011-01-12 09:08:48342/* Overrides for manpage documents */
343h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
348}
349h2 {
350 border-style: none;
351}
352div.sectionbody {
353 margin-left: 5%;
354}
355
356@media print {
357 div#toc { display: none; }
358}
359
Junio C Hamano2fbcd212008-05-14 22:26:07360/* Workarounds for IE6's broken and incomplete CSS2. */
361
362div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
366}
367div.sidebar-title, div.image-title {
Junio C Hamano81435632011-01-12 09:08:48368 color: #527bbd;
Junio C Hamano2fbcd212008-05-14 22:26:07369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
373}
374
375div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
379}
380
Junio C Hamano81435632011-01-12 09:08:48381div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
384}
385
386div.verseblock-content {
387 white-space: pre;
388}
389div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
Junio C Hamano2fbcd212008-05-14 22:26:07392}
393
394div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
397}
Junio C Hamanoba4b9282008-07-06 05:20:31398
399/* IE6 sets dynamically generated links as visited. */
400div#toc a:visited { color: blue; }
Junio C Hamano2fbcd212008-05-14 22:26:07401</style>
Junio C Hamano2fbcd212008-05-14 22:26:07402</head>
403<body>
404<div id="header">
405<h1>
406githooks(5) Manual Page
407</h1>
408<h2>NAME</h2>
409<div class="sectionbody">
410<p>githooks -
411 Hooks used by git
412</p>
413</div>
414</div>
Junio C Hamano81435632011-01-12 09:08:48415<h2 id="_synopsis">SYNOPSIS</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07416<div class="sectionbody">
Junio C Hamano81435632011-01-12 09:08:48417<div class="paragraph"><p>$GIT_DIR/hooks/*</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07418</div>
Junio C Hamanoba4b9282008-07-06 05:20:31419<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07420<div class="sectionbody">
Junio C Hamano81435632011-01-12 09:08:48421<div class="paragraph"><p>Hooks are little scripts you can place in <tt>$GIT_DIR/hooks</tt>
Junio C Hamano2fbcd212008-05-14 22:26:07422directory to trigger action at certain points. When
Junio C Hamano1aa40d22010-01-21 17:46:43423<em>git init</em> is run, a handful of example hooks are copied into the
Junio C Hamano2fbcd212008-05-14 22:26:07424<tt>hooks</tt> directory of the new repository, but by default they are
Junio C Hamano6aff3992008-06-25 08:07:44425all disabled. To enable a hook, rename it by removing its <tt>.sample</tt>
Junio C Hamanoba4b9282008-07-06 05:20:31426suffix.</p></div>
Junio C Hamano8a48fa22008-12-18 08:44:30427<div class="admonitionblock">
428<table><tr>
429<td class="icon">
430<div class="title">Note</div>
431</td>
432<td class="content">It is also a requirement for a given hook to be executable.
433However - in a freshly initialized repository - the <tt>.sample</tt> files are
434executable by default.</td>
435</tr></table>
436</div>
Junio C Hamano81435632011-01-12 09:08:48437<div class="paragraph"><p>This document describes the currently defined hooks.</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07438</div>
Junio C Hamanoc28068f2009-09-08 00:55:23439<h2 id="_hooks">HOOKS</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07440<div class="sectionbody">
Junio C Hamanoc28068f2009-09-08 00:55:23441<h3 id="_applypatch_msg">applypatch-msg</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48442<div class="paragraph"><p>This hook is invoked by <em>git am</em> script. It takes a single
Junio C Hamano2fbcd212008-05-14 22:26:07443parameter, the name of the file that holds the proposed commit
444log message. Exiting with non-zero status causes
Junio C Hamano1aa40d22010-01-21 17:46:43445<em>git am</em> to abort before applying the patch.</p></div>
Junio C Hamano81435632011-01-12 09:08:48446<div class="paragraph"><p>The hook is allowed to edit the message file in place, and can
Junio C Hamano2fbcd212008-05-14 22:26:07447be used to normalize the message into some project standard
448format (if the project has one). It can also be used to refuse
Junio C Hamanoba4b9282008-07-06 05:20:31449the commit after inspecting the message file.</p></div>
Junio C Hamano81435632011-01-12 09:08:48450<div class="paragraph"><p>The default <em>applypatch-msg</em> hook, when enabled, runs the
Junio C Hamanoba4b9282008-07-06 05:20:31451<em>commit-msg</em> hook, if the latter is enabled.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23452<h3 id="_pre_applypatch">pre-applypatch</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48453<div class="paragraph"><p>This hook is invoked by <em>git am</em>. It takes no parameter, and is
Junio C Hamanoba4b9282008-07-06 05:20:31454invoked after the patch is applied, but before a commit is made.</p></div>
Junio C Hamano81435632011-01-12 09:08:48455<div class="paragraph"><p>If it exits with non-zero status, then the working tree will not be
Junio C Hamanoba4b9282008-07-06 05:20:31456committed after applying the patch.</p></div>
Junio C Hamano81435632011-01-12 09:08:48457<div class="paragraph"><p>It can be used to inspect the current working tree and refuse to
Junio C Hamanoba4b9282008-07-06 05:20:31458make a commit if it does not pass certain test.</p></div>
Junio C Hamano81435632011-01-12 09:08:48459<div class="paragraph"><p>The default <em>pre-applypatch</em> hook, when enabled, runs the
Junio C Hamanoba4b9282008-07-06 05:20:31460<em>pre-commit</em> hook, if the latter is enabled.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23461<h3 id="_post_applypatch">post-applypatch</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48462<div class="paragraph"><p>This hook is invoked by <em>git am</em>. It takes no parameter,
Junio C Hamanoba4b9282008-07-06 05:20:31463and is invoked after the patch is applied and a commit is made.</p></div>
Junio C Hamano81435632011-01-12 09:08:48464<div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
Junio C Hamano1aa40d22010-01-21 17:46:43465the outcome of <em>git am</em>.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23466<h3 id="_pre_commit">pre-commit</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48467<div class="paragraph"><p>This hook is invoked by <em>git commit</em>, and can be bypassed
Junio C Hamano2fbcd212008-05-14 22:26:07468with <tt>--no-verify</tt> option. It takes no parameter, and is
469invoked before obtaining the proposed commit log message and
470making a commit. Exiting with non-zero status from this script
Junio C Hamano1aa40d22010-01-21 17:46:43471causes the <em>git commit</em> to abort.</p></div>
Junio C Hamano81435632011-01-12 09:08:48472<div class="paragraph"><p>The default <em>pre-commit</em> hook, when enabled, catches introduction
Junio C Hamano2fbcd212008-05-14 22:26:07473of lines with trailing whitespaces and aborts the commit when
Junio C Hamanoba4b9282008-07-06 05:20:31474such a line is found.</p></div>
Junio C Hamano81435632011-01-12 09:08:48475<div class="paragraph"><p>All the <em>git commit</em> hooks are invoked with the environment
Junio C Hamano2fbcd212008-05-14 22:26:07476variable <tt>GIT_EDITOR=:</tt> if the command will not bring up an editor
Junio C Hamanoba4b9282008-07-06 05:20:31477to modify the commit message.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23478<h3 id="_prepare_commit_msg">prepare-commit-msg</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48479<div class="paragraph"><p>This hook is invoked by <em>git commit</em> right after preparing the
Junio C Hamanoba4b9282008-07-06 05:20:31480default log message, and before the editor is started.</p></div>
Junio C Hamano81435632011-01-12 09:08:48481<div class="paragraph"><p>It takes one to three parameters. The first is the name of the file
Junio C Hamanobd53dbf2009-01-18 18:26:37482that contains the commit log message. The second is the source of the commit
Junio C Hamanoa476efa2008-10-10 15:31:42483message, and can be: <tt>message</tt> (if a <tt>-m</tt> or <tt>-F</tt> option was
484given); <tt>template</tt> (if a <tt>-t</tt> option was given or the
Junio C Hamano2fbcd212008-05-14 22:26:07485configuration option <tt>commit.template</tt> is set); <tt>merge</tt> (if the
486commit is a merge or a <tt>.git/MERGE_MSG</tt> file exists); <tt>squash</tt>
487(if a <tt>.git/SQUASH_MSG</tt> file exists); or <tt>commit</tt>, followed by
Junio C Hamanoa476efa2008-10-10 15:31:42488a commit SHA1 (if a <tt>-c</tt>, <tt>-C</tt> or <tt>--amend</tt> option was given).</p></div>
Junio C Hamano81435632011-01-12 09:08:48489<div class="paragraph"><p>If the exit status is non-zero, <em>git commit</em> will abort.</p></div>
490<div class="paragraph"><p>The purpose of the hook is to edit the message file in place, and
Junio C Hamano2fbcd212008-05-14 22:26:07491it is not suppressed by the <tt>--no-verify</tt> option. A non-zero exit
492means a failure of the hook and aborts the commit. It should not
Junio C Hamanoba4b9282008-07-06 05:20:31493be used as replacement for pre-commit hook.</p></div>
Junio C Hamano81435632011-01-12 09:08:48494<div class="paragraph"><p>The sample <tt>prepare-commit-msg</tt> hook that comes with git comments
495out the <tt>Conflicts:</tt> part of a merge&#8217;s commit message.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23496<h3 id="_commit_msg">commit-msg</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48497<div class="paragraph"><p>This hook is invoked by <em>git commit</em>, and can be bypassed
Junio C Hamano2fbcd212008-05-14 22:26:07498with <tt>--no-verify</tt> option. It takes a single parameter, the
499name of the file that holds the proposed commit log message.
Junio C Hamano1aa40d22010-01-21 17:46:43500Exiting with non-zero status causes the <em>git commit</em> to
Junio C Hamanoba4b9282008-07-06 05:20:31501abort.</p></div>
Junio C Hamano81435632011-01-12 09:08:48502<div class="paragraph"><p>The hook is allowed to edit the message file in place, and can
Junio C Hamano2fbcd212008-05-14 22:26:07503be used to normalize the message into some project standard
504format (if the project has one). It can also be used to refuse
Junio C Hamanoba4b9282008-07-06 05:20:31505the commit after inspecting the message file.</p></div>
Junio C Hamano81435632011-01-12 09:08:48506<div class="paragraph"><p>The default <em>commit-msg</em> hook, when enabled, detects duplicate
Junio C Hamanoba4b9282008-07-06 05:20:31507"Signed-off-by" lines, and aborts the commit if one is found.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23508<h3 id="_post_commit">post-commit</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48509<div class="paragraph"><p>This hook is invoked by <em>git commit</em>. It takes no
Junio C Hamanoba4b9282008-07-06 05:20:31510parameter, and is invoked after a commit is made.</p></div>
Junio C Hamano81435632011-01-12 09:08:48511<div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
Junio C Hamano1aa40d22010-01-21 17:46:43512the outcome of <em>git commit</em>.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23513<h3 id="_pre_rebase">pre-rebase</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48514<div class="paragraph"><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:42515from getting rebased.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23516<h3 id="_post_checkout">post-checkout</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48517<div class="paragraph"><p>This hook is invoked when a <em>git checkout</em> is run after having updated the
Junio C Hamano2fbcd212008-05-14 22:26:07518worktree. The hook is given three parameters: the ref of the previous HEAD,
519the ref of the new HEAD (which may or may not have changed), and a flag
520indicating whether the checkout was a branch checkout (changing branches,
521flag=1) or a file checkout (retrieving a file from the index, flag=0).
Junio C Hamano1aa40d22010-01-21 17:46:43522This hook cannot affect the outcome of <em>git checkout</em>.</p></div>
Junio C Hamano81435632011-01-12 09:08:48523<div class="paragraph"><p>It is also run after <em>git clone</em>, unless the --no-checkout (-n) option is
Junio C Hamano36a56722009-03-28 08:55:34524used. The first parameter given to the hook is the null-ref, the second the
525ref of the new HEAD and the flag is always 1.</p></div>
Junio C Hamano81435632011-01-12 09:08:48526<div class="paragraph"><p>This hook can be used to perform repository validity checks, auto-display
Junio C Hamano2fbcd212008-05-14 22:26:07527differences from the previous HEAD if different, or set working dir metadata
Junio C Hamanoba4b9282008-07-06 05:20:31528properties.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23529<h3 id="_post_merge">post-merge</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48530<div class="paragraph"><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:07531is done on a local repository. The hook takes a single parameter, a status
532flag specifying whether or not the merge being done was a squash merge.
Junio C Hamano1aa40d22010-01-21 17:46:43533This hook cannot affect the outcome of <em>git merge</em> and is not executed,
Junio C Hamanoba4b9282008-07-06 05:20:31534if the merge failed due to conflicts.</p></div>
Junio C Hamano81435632011-01-12 09:08:48535<div class="paragraph"><p>This hook can be used in conjunction with a corresponding pre-commit hook to
Junio C Hamano2fbcd212008-05-14 22:26:07536save and restore any form of metadata associated with the working tree
537(eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl
Junio C Hamanoba4b9282008-07-06 05:20:31538for an example of how to do this.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23539<h3 id="pre-receive">pre-receive</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48540<div class="paragraph"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
Junio C Hamano1aa40d22010-01-21 17:46:43541which happens when a <em>git push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07542Just before starting to update refs on the remote repository, the
543pre-receive hook is invoked. Its exit status determines the success
Junio C Hamanoba4b9282008-07-06 05:20:31544or failure of the update.</p></div>
Junio C Hamano81435632011-01-12 09:08:48545<div class="paragraph"><p>This hook executes once for the receive operation. It takes no
Junio C Hamano2fbcd212008-05-14 22:26:07546arguments, but for each ref to be updated it receives on standard
Junio C Hamanoba4b9282008-07-06 05:20:31547input a line of the format:</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07548<div class="literalblock">
549<div class="content">
550<pre><tt>&lt;old-value&gt; SP &lt;new-value&gt; SP &lt;ref-name&gt; LF</tt></pre>
551</div></div>
Junio C Hamano81435632011-01-12 09:08:48552<div class="paragraph"><p>where <tt>&lt;old-value&gt;</tt> is the old object name stored in the ref,
Junio C Hamano2fbcd212008-05-14 22:26:07553<tt>&lt;new-value&gt;</tt> is the new object name to be stored in the ref and
554<tt>&lt;ref-name&gt;</tt> is the full name of the ref.
Junio C Hamanoba4b9282008-07-06 05:20:31555When creating a new ref, <tt>&lt;old-value&gt;</tt> is 40 <tt>0</tt>.</p></div>
Junio C Hamano81435632011-01-12 09:08:48556<div class="paragraph"><p>If the hook exits with non-zero status, none of the refs will be
Junio C Hamano2fbcd212008-05-14 22:26:07557updated. If the hook exits with zero, updating of individual refs can
Junio C Hamanoba4b9282008-07-06 05:20:31558still be prevented by the <a href="#update"><em>update</em></a> hook.</p></div>
Junio C Hamano81435632011-01-12 09:08:48559<div class="paragraph"><p>Both standard output and standard error output are forwarded to
Junio C Hamano1aa40d22010-01-21 17:46:43560<em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
Junio C Hamanoba4b9282008-07-06 05:20:31561for the user.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23562<h3 id="update">update</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48563<div class="paragraph"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
Junio C Hamano1aa40d22010-01-21 17:46:43564which happens when a <em>git push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07565Just before updating the ref on the remote repository, the update hook
566is invoked. Its exit status determines the success or failure of
Junio C Hamanoba4b9282008-07-06 05:20:31567the ref update.</p></div>
Junio C Hamano81435632011-01-12 09:08:48568<div class="paragraph"><p>The hook executes once for each ref to be updated, and takes
Junio C Hamanoba4b9282008-07-06 05:20:31569three parameters:</p></div>
Junio C Hamano81435632011-01-12 09:08:48570<div class="ulist"><ul>
Junio C Hamano2fbcd212008-05-14 22:26:07571<li>
572<p>
573the name of the ref being updated,
574</p>
575</li>
576<li>
577<p>
578the old object name stored in the ref,
579</p>
580</li>
581<li>
582<p>
583and the new objectname to be stored in the ref.
584</p>
585</li>
Junio C Hamanoba4b9282008-07-06 05:20:31586</ul></div>
Junio C Hamano81435632011-01-12 09:08:48587<div class="paragraph"><p>A zero exit from the update hook allows the ref to be updated.
Junio C Hamanoba4b9282008-07-06 05:20:31588Exiting with a non-zero status prevents <em>git-receive-pack</em>
589from updating that ref.</p></div>
Junio C Hamano81435632011-01-12 09:08:48590<div class="paragraph"><p>This hook can be used to prevent <em>forced</em> update on certain refs by
Junio C Hamano2fbcd212008-05-14 22:26:07591making sure that the object name is a commit object that is a
592descendant of the commit object named by the old object name.
Junio C Hamano3f680f32009-11-16 02:10:54593That is, to enforce a "fast-forward only" policy.</p></div>
Junio C Hamano81435632011-01-12 09:08:48594<div class="paragraph"><p>It could also be used to log the old..new status. However, it
Junio C Hamano2fbcd212008-05-14 22:26:07595does not know the entire set of branches, so it would end up
596firing one e-mail per ref when used naively, though. The
Junio C Hamanoba4b9282008-07-06 05:20:31597<a href="#post-receive"><em>post-receive</em></a> hook is more suited to that.</p></div>
Junio C Hamano81435632011-01-12 09:08:48598<div class="paragraph"><p>Another use suggested on the mailing list is to use this hook to
Junio C Hamano2fbcd212008-05-14 22:26:07599implement access control which is finer grained than the one
Junio C Hamanoba4b9282008-07-06 05:20:31600based on filesystem group.</p></div>
Junio C Hamano81435632011-01-12 09:08:48601<div class="paragraph"><p>Both standard output and standard error output are forwarded to
Junio C Hamano1aa40d22010-01-21 17:46:43602<em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
Junio C Hamanoba4b9282008-07-06 05:20:31603for the user.</p></div>
Junio C Hamano81435632011-01-12 09:08:48604<div class="paragraph"><p>The default <em>update</em> hook, when enabled&#8212;and with
605<tt>hooks.allowunannotated</tt> config option unset or set to false&#8212;prevents
Junio C Hamanoba4b9282008-07-06 05:20:31606unannotated tags to be pushed.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23607<h3 id="post-receive">post-receive</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48608<div class="paragraph"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
Junio C Hamano1aa40d22010-01-21 17:46:43609which happens when a <em>git push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07610It executes on the remote repository once after all the refs have
Junio C Hamanoba4b9282008-07-06 05:20:31611been updated.</p></div>
Junio C Hamano81435632011-01-12 09:08:48612<div class="paragraph"><p>This hook executes once for the receive operation. It takes no
Junio C Hamano2fbcd212008-05-14 22:26:07613arguments, but gets the same information as the
614<a href="#pre-receive"><em>pre-receive</em></a>
Junio C Hamanoba4b9282008-07-06 05:20:31615hook does on its standard input.</p></div>
Junio C Hamano81435632011-01-12 09:08:48616<div class="paragraph"><p>This hook does not affect the outcome of <em>git-receive-pack</em>, as it
Junio C Hamanoba4b9282008-07-06 05:20:31617is called after the real work is done.</p></div>
Junio C Hamano81435632011-01-12 09:08:48618<div class="paragraph"><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:07619both old and new values of all the refs in addition to their
Junio C Hamanoba4b9282008-07-06 05:20:31620names.</p></div>
Junio C Hamano81435632011-01-12 09:08:48621<div class="paragraph"><p>Both standard output and standard error output are forwarded to
Junio C Hamano1aa40d22010-01-21 17:46:43622<em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
Junio C Hamanoba4b9282008-07-06 05:20:31623for the user.</p></div>
Junio C Hamano81435632011-01-12 09:08:48624<div class="paragraph"><p>The default <em>post-receive</em> hook is empty, but there is
Junio C Hamano2fbcd212008-05-14 22:26:07625a sample script <tt>post-receive-email</tt> provided in the <tt>contrib/hooks</tt>
626directory in git distribution, which implements sending commit
Junio C Hamanoba4b9282008-07-06 05:20:31627emails.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23628<h3 id="post-update">post-update</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48629<div class="paragraph"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
Junio C Hamano1aa40d22010-01-21 17:46:43630which happens when a <em>git push</em> is done on a local repository.
Junio C Hamano2fbcd212008-05-14 22:26:07631It executes on the remote repository once after all the refs have
Junio C Hamanoba4b9282008-07-06 05:20:31632been updated.</p></div>
Junio C Hamano81435632011-01-12 09:08:48633<div class="paragraph"><p>It takes a variable number of parameters, each of which is the
Junio C Hamanoba4b9282008-07-06 05:20:31634name of ref that was actually updated.</p></div>
Junio C Hamano81435632011-01-12 09:08:48635<div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
Junio C Hamanoba4b9282008-07-06 05:20:31636the outcome of <em>git-receive-pack</em>.</p></div>
Junio C Hamano81435632011-01-12 09:08:48637<div class="paragraph"><p>The <em>post-update</em> hook can tell what are the heads that were pushed,
Junio C Hamano2fbcd212008-05-14 22:26:07638but it does not know what their original and updated values are,
639so it is a poor place to do log old..new. The
640<a href="#post-receive"><em>post-receive</em></a> hook does get both original and
641updated values of the refs. You might consider it instead if you need
Junio C Hamanoba4b9282008-07-06 05:20:31642them.</p></div>
Junio C Hamano81435632011-01-12 09:08:48643<div class="paragraph"><p>When enabled, the default <em>post-update</em> hook runs
Junio C Hamano1aa40d22010-01-21 17:46:43644<em>git update-server-info</em> to keep the information used by dumb
Junio C Hamano2fbcd212008-05-14 22:26:07645transports (e.g., HTTP) up-to-date. If you are publishing
646a git repository that is accessible via HTTP, you should
Junio C Hamanoba4b9282008-07-06 05:20:31647probably enable this hook.</p></div>
Junio C Hamano81435632011-01-12 09:08:48648<div class="paragraph"><p>Both standard output and standard error output are forwarded to
Junio C Hamano1aa40d22010-01-21 17:46:43649<em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
Junio C Hamanoba4b9282008-07-06 05:20:31650for the user.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23651<h3 id="_pre_auto_gc">pre-auto-gc</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48652<div class="paragraph"><p>This hook is invoked by <em>git gc --auto</em>. It takes no parameter, and
Junio C Hamano1aa40d22010-01-21 17:46:43653exiting with non-zero status from this script causes the <em>git gc --auto</em>
Junio C Hamanoba4b9282008-07-06 05:20:31654to abort.</p></div>
Junio C Hamano31667362010-03-25 00:38:53655<h3 id="_post_rewrite">post-rewrite</h3><div style="clear:left"></div>
Junio C Hamano81435632011-01-12 09:08:48656<div class="paragraph"><p>This hook is invoked by commands that rewrite commits (<tt>git commit
Junio C Hamano31667362010-03-25 00:38:53657--amend</tt>, <em>git-rebase</em>; currently <em>git-filter-branch</em> does <em>not</em> call
658it!). Its first argument denotes the command it was invoked by:
659currently one of <tt>amend</tt> or <tt>rebase</tt>. Further command-dependent
660arguments may be passed in the future.</p></div>
Junio C Hamano81435632011-01-12 09:08:48661<div class="paragraph"><p>The hook receives a list of the rewritten commits on stdin, in the
Junio C Hamano31667362010-03-25 00:38:53662format</p></div>
663<div class="literalblock">
664<div class="content">
665<pre><tt>&lt;old-sha1&gt; SP &lt;new-sha1&gt; [ SP &lt;extra-info&gt; ] LF</tt></pre>
666</div></div>
Junio C Hamano81435632011-01-12 09:08:48667<div class="paragraph"><p>The <em>extra-info</em> is again command-dependent. If it is empty, the
Junio C Hamano31667362010-03-25 00:38:53668preceding SP is also omitted. Currently, no commands pass any
669<em>extra-info</em>.</p></div>
Junio C Hamano81435632011-01-12 09:08:48670<div class="paragraph"><p>The hook always runs after the automatic note copying (see
Junio C Hamano31667362010-03-25 00:38:53671"notes.rewrite.&lt;command&gt;" in linkgit:git-config.txt) has happened, and
672thus has access to these notes.</p></div>
Junio C Hamano81435632011-01-12 09:08:48673<div class="paragraph"><p>The following command-specific comments apply:</p></div>
674<div class="dlist"><dl>
675<dt class="hdlist1">
Junio C Hamano31667362010-03-25 00:38:53676rebase
677</dt>
678<dd>
679<p>
680 For the <em>squash</em> and <em>fixup</em> operation, all commits that were
681 squashed are listed as being rewritten to the squashed commit.
682 This means that there will be several lines sharing the same
683 <em>new-sha1</em>.
684</p>
Junio C Hamano81435632011-01-12 09:08:48685<div class="paragraph"><p>The commits are guaranteed to be listed in the order that they were
Junio C Hamano31667362010-03-25 00:38:53686processed by rebase.</p></div>
687</dd>
688</dl></div>
Junio C Hamano2fbcd212008-05-14 22:26:07689</div>
Junio C Hamanoba4b9282008-07-06 05:20:31690<h2 id="_git">GIT</h2>
Junio C Hamano2fbcd212008-05-14 22:26:07691<div class="sectionbody">
Junio C Hamano81435632011-01-12 09:08:48692<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano2fbcd212008-05-14 22:26:07693</div>
694<div id="footer">
695<div id="footer-text">
Junio C Hamano81435632011-01-12 09:08:48696Last updated 2011-01-12 09:08:33 UTC
Junio C Hamano2fbcd212008-05-14 22:26:07697</div>
698</div>
699</body>
700</html>