Autogenerated HTML docs for v1.7.7-290-gc9e7aa
[git/jnareb-git.git] / githooks.html
blobf352183b382ca926c4d8fb3c85e053e7fb6ddccc
1 <!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" />
6 <meta name="generator" content="AsciiDoc 8.5.2" />
7 <title>githooks(5)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, 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;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#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;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.0em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
131 div.content { /* Block element content. */
132 padding: 0;
135 /* Block element titles. */
136 div.title, caption.title {
137 color: #527bbd;
138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
144 div.title + * {
145 margin-top: 0;
148 td div.title:first-child {
149 margin-top: 0.0em;
151 div.content div.title:first-child {
152 margin-top: 0.0em;
154 div.content + div.title {
155 margin-top: 0.0em;
158 div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
164 div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
170 div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
173 margin-right: 10%;
174 border-left: 5px solid #dddddd;
175 color: #777777;
178 div.quoteblock > div.attribution {
179 padding-top: 0.5em;
180 text-align: right;
183 div.verseblock > div.content {
184 white-space: pre;
186 div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div.verseblock + div.attribution {
192 text-align: left;
195 div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
203 div.admonitionblock td.content {
204 padding-left: 0.5em;
205 border-left: 3px solid #dddddd;
208 div.exampleblock > div.content {
209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
213 div.imageblock div.content { padding-left: 0; }
214 span.image img { border-style: none; }
215 a.image:visited { color: white; }
217 dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
221 dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
224 font-style: normal;
225 color: navy;
227 dd > *:first-child {
228 margin-top: 0.1em;
231 ul, ol {
232 list-style-position: outside;
234 ol.arabic {
235 list-style-type: decimal;
237 ol.loweralpha {
238 list-style-type: lower-alpha;
240 ol.upperalpha {
241 list-style-type: upper-alpha;
243 ol.lowerroman {
244 list-style-type: lower-roman;
246 ol.upperroman {
247 list-style-type: upper-roman;
250 div.compact ul, div.compact ol,
251 div.compact p, div.compact p,
252 div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
257 div.tableblock > table {
258 border: 3px solid #527bbd;
260 thead, p.table.header {
261 font-family: sans-serif;
262 font-weight: bold;
264 tfoot {
265 font-weight: bold;
267 td > div.verse {
268 white-space: pre;
270 p.table {
271 margin-top: 0;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div.tableblock > table[frame="void"] {
275 border-style: none;
277 div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
281 div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
287 div.hdlist {
288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
291 div.hdlist tr {
292 padding-bottom: 15px;
294 dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
297 td.hdlist1 {
298 vertical-align: top;
299 font-style: normal;
300 padding-right: 0.8em;
301 color: navy;
303 td.hdlist2 {
304 vertical-align: top;
306 div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
311 .comment {
312 background: yellow;
315 .footnote, .footnoteref {
316 font-size: 0.8em;
319 span.footnote, span.footnoteref {
320 vertical-align: super;
323 #footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
328 #footnotes div.footnote {
329 margin: 0 0 5px 0;
332 #footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
343 @media print {
344 div#footer-badges { display: none; }
347 div#toc {
348 margin-bottom: 2.5em;
351 div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
360 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
364 div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
368 div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
372 div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
376 /* Overrides for manpage documents */
377 h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
383 h2 {
384 border-style: none;
386 div.sectionbody {
387 margin-left: 5%;
390 @media print {
391 div#toc { display: none; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
401 div.sidebar-title, div.image-title {
402 color: #527bbd;
403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
409 div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
415 div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
420 div.verseblock-content {
421 white-space: pre;
423 div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
428 div.exampleblock-content {
429 border-left: 3px solid #dddddd;
430 padding-left: 0.5em;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc a:visited { color: blue; }
435 </style>
436 <script type="text/javascript">
437 /*<![CDATA[*/
438 window.onload = function(){asciidoc.footnotes();}
439 var asciidoc = { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
449 * Version: 0.4
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
458 // toclevels = 1..4.
459 toc: function (toclevels) {
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
469 return text;
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
491 iterate(i);
495 iterate(el);
496 return result;
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
567 /*]]>*/
568 </script>
569 </head>
570 <body>
571 <div id="header">
572 <h1>
573 githooks(5) Manual Page
574 </h1>
575 <h2>NAME</h2>
576 <div class="sectionbody">
577 <p>githooks -
578 Hooks used by git
579 </p>
580 </div>
581 </div>
582 <div id="content">
583 <h2 id="_synopsis">SYNOPSIS</h2>
584 <div class="sectionbody">
585 <div class="paragraph"><p>$GIT_DIR/hooks/*</p></div>
586 </div>
587 <h2 id="_description">DESCRIPTION</h2>
588 <div class="sectionbody">
589 <div class="paragraph"><p>Hooks are little scripts you can place in <tt>$GIT_DIR/hooks</tt>
590 directory to trigger action at certain points. When
591 <em>git init</em> is run, a handful of example hooks are copied into the
592 <tt>hooks</tt> directory of the new repository, but by default they are
593 all disabled. To enable a hook, rename it by removing its <tt>.sample</tt>
594 suffix.</p></div>
595 <div class="admonitionblock">
596 <table><tr>
597 <td class="icon">
598 <div class="title">Note</div>
599 </td>
600 <td class="content">It is also a requirement for a given hook to be executable.
601 However - in a freshly initialized repository - the <tt>.sample</tt> files are
602 executable by default.</td>
603 </tr></table>
604 </div>
605 <div class="paragraph"><p>This document describes the currently defined hooks.</p></div>
606 </div>
607 <h2 id="_hooks">HOOKS</h2>
608 <div class="sectionbody">
609 <h3 id="_applypatch_msg">applypatch-msg</h3><div style="clear:left"></div>
610 <div class="paragraph"><p>This hook is invoked by <em>git am</em> script. It takes a single
611 parameter, the name of the file that holds the proposed commit
612 log message. Exiting with non-zero status causes
613 <em>git am</em> to abort before applying the patch.</p></div>
614 <div class="paragraph"><p>The hook is allowed to edit the message file in place, and can
615 be used to normalize the message into some project standard
616 format (if the project has one). It can also be used to refuse
617 the commit after inspecting the message file.</p></div>
618 <div class="paragraph"><p>The default <em>applypatch-msg</em> hook, when enabled, runs the
619 <em>commit-msg</em> hook, if the latter is enabled.</p></div>
620 <h3 id="_pre_applypatch">pre-applypatch</h3><div style="clear:left"></div>
621 <div class="paragraph"><p>This hook is invoked by <em>git am</em>. It takes no parameter, and is
622 invoked after the patch is applied, but before a commit is made.</p></div>
623 <div class="paragraph"><p>If it exits with non-zero status, then the working tree will not be
624 committed after applying the patch.</p></div>
625 <div class="paragraph"><p>It can be used to inspect the current working tree and refuse to
626 make a commit if it does not pass certain test.</p></div>
627 <div class="paragraph"><p>The default <em>pre-applypatch</em> hook, when enabled, runs the
628 <em>pre-commit</em> hook, if the latter is enabled.</p></div>
629 <h3 id="_post_applypatch">post-applypatch</h3><div style="clear:left"></div>
630 <div class="paragraph"><p>This hook is invoked by <em>git am</em>. It takes no parameter,
631 and is invoked after the patch is applied and a commit is made.</p></div>
632 <div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
633 the outcome of <em>git am</em>.</p></div>
634 <h3 id="_pre_commit">pre-commit</h3><div style="clear:left"></div>
635 <div class="paragraph"><p>This hook is invoked by <em>git commit</em>, and can be bypassed
636 with <tt>--no-verify</tt> option. It takes no parameter, and is
637 invoked before obtaining the proposed commit log message and
638 making a commit. Exiting with non-zero status from this script
639 causes the <em>git commit</em> to abort.</p></div>
640 <div class="paragraph"><p>The default <em>pre-commit</em> hook, when enabled, catches introduction
641 of lines with trailing whitespaces and aborts the commit when
642 such a line is found.</p></div>
643 <div class="paragraph"><p>All the <em>git commit</em> hooks are invoked with the environment
644 variable <tt>GIT_EDITOR=:</tt> if the command will not bring up an editor
645 to modify the commit message.</p></div>
646 <h3 id="_prepare_commit_msg">prepare-commit-msg</h3><div style="clear:left"></div>
647 <div class="paragraph"><p>This hook is invoked by <em>git commit</em> right after preparing the
648 default log message, and before the editor is started.</p></div>
649 <div class="paragraph"><p>It takes one to three parameters. The first is the name of the file
650 that contains the commit log message. The second is the source of the commit
651 message, and can be: <tt>message</tt> (if a <tt>-m</tt> or <tt>-F</tt> option was
652 given); <tt>template</tt> (if a <tt>-t</tt> option was given or the
653 configuration option <tt>commit.template</tt> is set); <tt>merge</tt> (if the
654 commit is a merge or a <tt>.git/MERGE_MSG</tt> file exists); <tt>squash</tt>
655 (if a <tt>.git/SQUASH_MSG</tt> file exists); or <tt>commit</tt>, followed by
656 a commit SHA1 (if a <tt>-c</tt>, <tt>-C</tt> or <tt>--amend</tt> option was given).</p></div>
657 <div class="paragraph"><p>If the exit status is non-zero, <em>git commit</em> will abort.</p></div>
658 <div class="paragraph"><p>The purpose of the hook is to edit the message file in place, and
659 it is not suppressed by the <tt>--no-verify</tt> option. A non-zero exit
660 means a failure of the hook and aborts the commit. It should not
661 be used as replacement for pre-commit hook.</p></div>
662 <div class="paragraph"><p>The sample <tt>prepare-commit-msg</tt> hook that comes with git comments
663 out the <tt>Conflicts:</tt> part of a merge&#8217;s commit message.</p></div>
664 <h3 id="_commit_msg">commit-msg</h3><div style="clear:left"></div>
665 <div class="paragraph"><p>This hook is invoked by <em>git commit</em>, and can be bypassed
666 with <tt>--no-verify</tt> option. It takes a single parameter, the
667 name of the file that holds the proposed commit log message.
668 Exiting with non-zero status causes the <em>git commit</em> to
669 abort.</p></div>
670 <div class="paragraph"><p>The hook is allowed to edit the message file in place, and can
671 be used to normalize the message into some project standard
672 format (if the project has one). It can also be used to refuse
673 the commit after inspecting the message file.</p></div>
674 <div class="paragraph"><p>The default <em>commit-msg</em> hook, when enabled, detects duplicate
675 "Signed-off-by" lines, and aborts the commit if one is found.</p></div>
676 <h3 id="_post_commit">post-commit</h3><div style="clear:left"></div>
677 <div class="paragraph"><p>This hook is invoked by <em>git commit</em>. It takes no
678 parameter, and is invoked after a commit is made.</p></div>
679 <div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
680 the outcome of <em>git commit</em>.</p></div>
681 <h3 id="_pre_rebase">pre-rebase</h3><div style="clear:left"></div>
682 <div class="paragraph"><p>This hook is called by <em>git rebase</em> and can be used to prevent a branch
683 from getting rebased.</p></div>
684 <h3 id="_post_checkout">post-checkout</h3><div style="clear:left"></div>
685 <div class="paragraph"><p>This hook is invoked when a <em>git checkout</em> is run after having updated the
686 worktree. The hook is given three parameters: the ref of the previous HEAD,
687 the ref of the new HEAD (which may or may not have changed), and a flag
688 indicating whether the checkout was a branch checkout (changing branches,
689 flag=1) or a file checkout (retrieving a file from the index, flag=0).
690 This hook cannot affect the outcome of <em>git checkout</em>.</p></div>
691 <div class="paragraph"><p>It is also run after <em>git clone</em>, unless the --no-checkout (-n) option is
692 used. The first parameter given to the hook is the null-ref, the second the
693 ref of the new HEAD and the flag is always 1.</p></div>
694 <div class="paragraph"><p>This hook can be used to perform repository validity checks, auto-display
695 differences from the previous HEAD if different, or set working dir metadata
696 properties.</p></div>
697 <h3 id="_post_merge">post-merge</h3><div style="clear:left"></div>
698 <div class="paragraph"><p>This hook is invoked by <em>git merge</em>, which happens when a <em>git pull</em>
699 is done on a local repository. The hook takes a single parameter, a status
700 flag specifying whether or not the merge being done was a squash merge.
701 This hook cannot affect the outcome of <em>git merge</em> and is not executed,
702 if the merge failed due to conflicts.</p></div>
703 <div class="paragraph"><p>This hook can be used in conjunction with a corresponding pre-commit hook to
704 save and restore any form of metadata associated with the working tree
705 (eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl
706 for an example of how to do this.</p></div>
707 <h3 id="pre-receive">pre-receive</h3><div style="clear:left"></div>
708 <div class="paragraph"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
709 which happens when a <em>git push</em> is done on a local repository.
710 Just before starting to update refs on the remote repository, the
711 pre-receive hook is invoked. Its exit status determines the success
712 or failure of the update.</p></div>
713 <div class="paragraph"><p>This hook executes once for the receive operation. It takes no
714 arguments, but for each ref to be updated it receives on standard
715 input a line of the format:</p></div>
716 <div class="literalblock">
717 <div class="content">
718 <pre><tt>&lt;old-value&gt; SP &lt;new-value&gt; SP &lt;ref-name&gt; LF</tt></pre>
719 </div></div>
720 <div class="paragraph"><p>where <tt>&lt;old-value&gt;</tt> is the old object name stored in the ref,
721 <tt>&lt;new-value&gt;</tt> is the new object name to be stored in the ref and
722 <tt>&lt;ref-name&gt;</tt> is the full name of the ref.
723 When creating a new ref, <tt>&lt;old-value&gt;</tt> is 40 <tt>0</tt>.</p></div>
724 <div class="paragraph"><p>If the hook exits with non-zero status, none of the refs will be
725 updated. If the hook exits with zero, updating of individual refs can
726 still be prevented by the <a href="#update"><em>update</em></a> hook.</p></div>
727 <div class="paragraph"><p>Both standard output and standard error output are forwarded to
728 <em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
729 for the user.</p></div>
730 <h3 id="update">update</h3><div style="clear:left"></div>
731 <div class="paragraph"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
732 which happens when a <em>git push</em> is done on a local repository.
733 Just before updating the ref on the remote repository, the update hook
734 is invoked. Its exit status determines the success or failure of
735 the ref update.</p></div>
736 <div class="paragraph"><p>The hook executes once for each ref to be updated, and takes
737 three parameters:</p></div>
738 <div class="ulist"><ul>
739 <li>
741 the name of the ref being updated,
742 </p>
743 </li>
744 <li>
746 the old object name stored in the ref,
747 </p>
748 </li>
749 <li>
751 and the new objectname to be stored in the ref.
752 </p>
753 </li>
754 </ul></div>
755 <div class="paragraph"><p>A zero exit from the update hook allows the ref to be updated.
756 Exiting with a non-zero status prevents <em>git-receive-pack</em>
757 from updating that ref.</p></div>
758 <div class="paragraph"><p>This hook can be used to prevent <em>forced</em> update on certain refs by
759 making sure that the object name is a commit object that is a
760 descendant of the commit object named by the old object name.
761 That is, to enforce a "fast-forward only" policy.</p></div>
762 <div class="paragraph"><p>It could also be used to log the old..new status. However, it
763 does not know the entire set of branches, so it would end up
764 firing one e-mail per ref when used naively, though. The
765 <a href="#post-receive"><em>post-receive</em></a> hook is more suited to that.</p></div>
766 <div class="paragraph"><p>Another use suggested on the mailing list is to use this hook to
767 implement access control which is finer grained than the one
768 based on filesystem group.</p></div>
769 <div class="paragraph"><p>Both standard output and standard error output are forwarded to
770 <em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
771 for the user.</p></div>
772 <div class="paragraph"><p>The default <em>update</em> hook, when enabled&#8212;and with
773 <tt>hooks.allowunannotated</tt> config option unset or set to false&#8212;prevents
774 unannotated tags to be pushed.</p></div>
775 <h3 id="post-receive">post-receive</h3><div style="clear:left"></div>
776 <div class="paragraph"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
777 which happens when a <em>git push</em> is done on a local repository.
778 It executes on the remote repository once after all the refs have
779 been updated.</p></div>
780 <div class="paragraph"><p>This hook executes once for the receive operation. It takes no
781 arguments, but gets the same information as the
782 <a href="#pre-receive"><em>pre-receive</em></a>
783 hook does on its standard input.</p></div>
784 <div class="paragraph"><p>This hook does not affect the outcome of <em>git-receive-pack</em>, as it
785 is called after the real work is done.</p></div>
786 <div class="paragraph"><p>This supersedes the <a href="#post-update"><em>post-update</em></a> hook in that it gets
787 both old and new values of all the refs in addition to their
788 names.</p></div>
789 <div class="paragraph"><p>Both standard output and standard error output are forwarded to
790 <em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
791 for the user.</p></div>
792 <div class="paragraph"><p>The default <em>post-receive</em> hook is empty, but there is
793 a sample script <tt>post-receive-email</tt> provided in the <tt>contrib/hooks</tt>
794 directory in git distribution, which implements sending commit
795 emails.</p></div>
796 <h3 id="post-update">post-update</h3><div style="clear:left"></div>
797 <div class="paragraph"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository,
798 which happens when a <em>git push</em> is done on a local repository.
799 It executes on the remote repository once after all the refs have
800 been updated.</p></div>
801 <div class="paragraph"><p>It takes a variable number of parameters, each of which is the
802 name of ref that was actually updated.</p></div>
803 <div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
804 the outcome of <em>git-receive-pack</em>.</p></div>
805 <div class="paragraph"><p>The <em>post-update</em> hook can tell what are the heads that were pushed,
806 but it does not know what their original and updated values are,
807 so it is a poor place to do log old..new. The
808 <a href="#post-receive"><em>post-receive</em></a> hook does get both original and
809 updated values of the refs. You might consider it instead if you need
810 them.</p></div>
811 <div class="paragraph"><p>When enabled, the default <em>post-update</em> hook runs
812 <em>git update-server-info</em> to keep the information used by dumb
813 transports (e.g., HTTP) up-to-date. If you are publishing
814 a git repository that is accessible via HTTP, you should
815 probably enable this hook.</p></div>
816 <div class="paragraph"><p>Both standard output and standard error output are forwarded to
817 <em>git send-pack</em> on the other end, so you can simply <tt>echo</tt> messages
818 for the user.</p></div>
819 <h3 id="_pre_auto_gc">pre-auto-gc</h3><div style="clear:left"></div>
820 <div class="paragraph"><p>This hook is invoked by <em>git gc --auto</em>. It takes no parameter, and
821 exiting with non-zero status from this script causes the <em>git gc --auto</em>
822 to abort.</p></div>
823 <h3 id="_post_rewrite">post-rewrite</h3><div style="clear:left"></div>
824 <div class="paragraph"><p>This hook is invoked by commands that rewrite commits (<tt>git commit
825 --amend</tt>, <em>git-rebase</em>; currently <em>git-filter-branch</em> does <em>not</em> call
826 it!). Its first argument denotes the command it was invoked by:
827 currently one of <tt>amend</tt> or <tt>rebase</tt>. Further command-dependent
828 arguments may be passed in the future.</p></div>
829 <div class="paragraph"><p>The hook receives a list of the rewritten commits on stdin, in the
830 format</p></div>
831 <div class="literalblock">
832 <div class="content">
833 <pre><tt>&lt;old-sha1&gt; SP &lt;new-sha1&gt; [ SP &lt;extra-info&gt; ] LF</tt></pre>
834 </div></div>
835 <div class="paragraph"><p>The <em>extra-info</em> is again command-dependent. If it is empty, the
836 preceding SP is also omitted. Currently, no commands pass any
837 <em>extra-info</em>.</p></div>
838 <div class="paragraph"><p>The hook always runs after the automatic note copying (see
839 "notes.rewrite.&lt;command&gt;" in linkgit:git-config.txt) has happened, and
840 thus has access to these notes.</p></div>
841 <div class="paragraph"><p>The following command-specific comments apply:</p></div>
842 <div class="dlist"><dl>
843 <dt class="hdlist1">
844 rebase
845 </dt>
846 <dd>
848 For the <em>squash</em> and <em>fixup</em> operation, all commits that were
849 squashed are listed as being rewritten to the squashed commit.
850 This means that there will be several lines sharing the same
851 <em>new-sha1</em>.
852 </p>
853 <div class="paragraph"><p>The commits are guaranteed to be listed in the order that they were
854 processed by rebase.</p></div>
855 </dd>
856 </dl></div>
857 </div>
858 <h2 id="_git">GIT</h2>
859 <div class="sectionbody">
860 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
861 </div>
862 </div>
863 <div id="footnotes"><hr /></div>
864 <div id="footer">
865 <div id="footer-text">
866 Last updated 2011-09-21 23:01:14 PDT
867 </div>
868 </div>
869 </body>
870 </html>