Autogenerated HTML docs for v2.45.0-rc0
[git-htmldocs.git] / githooks.html
blob8fe90a7befac830aefd9628d812aa006177ee63e
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
7 <meta name="generator" content="AsciiDoc 10.2.0" />
8 <title>githooks(5)</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
27 body {
28 margin: 1em 5% 1em 5%;
31 a {
32 color: blue;
33 text-decoration: underline;
35 a:visited {
36 color: fuchsia;
39 em {
40 font-style: italic;
41 color: navy;
44 strong {
45 font-weight: bold;
46 color: #083194;
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
59 h2 {
60 padding-top: 0.5em;
62 h3 {
63 float: left;
65 h3 + * {
66 clear: left;
68 h5 {
69 font-size: 1.0em;
72 div.sectionbody {
73 margin-left: 0;
76 hr {
77 border: 1px solid silver;
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
85 ul, ol, li > p {
86 margin-top: 0;
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
98 pre {
99 white-space: pre-wrap;
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
107 #email {
109 #revnumber, #revdate, #revremark {
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
144 div.content { /* Block element content. */
145 padding: 0;
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
156 div.title + * {
157 margin-top: 0;
160 td div.title:first-child {
161 margin-top: 0.0em;
163 div.content div.title:first-child {
164 margin-top: 0.0em;
166 div.content + div.title {
167 margin-top: 0.0em;
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
228 div.imageblock div.content { padding-left: 0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
242 dd > *:first-child {
243 margin-top: 0.1em;
246 ul, ol {
247 list-style-position: outside;
249 ol.arabic {
250 list-style-type: decimal;
252 ol.loweralpha {
253 list-style-type: lower-alpha;
255 ol.upperalpha {
256 list-style-type: upper-alpha;
258 ol.lowerroman {
259 list-style-type: lower-roman;
261 ol.upperroman {
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
272 tfoot {
273 font-weight: bold;
275 td > div.verse {
276 white-space: pre;
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
283 div.hdlist tr {
284 padding-bottom: 15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
295 td.hdlist2 {
296 vertical-align: top;
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
303 .comment {
304 background: yellow;
307 .footnote, .footnoteref {
308 font-size: 0.8em;
311 span.footnote, span.footnoteref {
312 vertical-align: super;
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
339 div.colist td img {
340 margin-top: 0.3em;
343 @media print {
344 #footer-badges { display: none; }
347 #toc {
348 margin-bottom: 2.5em;
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
421 * xhtml11 specific
423 * */
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
429 div.tableblock > table {
430 border: 3px solid #527bbd;
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
436 p.table {
437 margin-top: 0;
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
454 * html5 specific
456 * */
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
466 p.tableblock {
467 margin-top: 0;
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
517 * manpage specific
519 * */
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
527 body.manpage h2 {
528 border-style: none;
530 body.manpage div.sectionbody {
531 margin-left: 3em;
534 @media print {
535 body.manpage div#toc { display: none; }
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
552 * Version: 0.4
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
561 // toclevels = 1..4.
562 toc: function (toclevels) {
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
572 return text;
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
586 // browsers).
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
594 iterate(i);
598 iterate(el);
599 return result;
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
610 for (i = 0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById("content"), toclevels);
623 for (var i = 0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id == "")
626 entry.element.id = "_toc_" + i;
627 var a = document.createElement("a");
628 a.href = "#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement("div");
631 div.appendChild(a);
632 div.className = "toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
659 entriesToRemove.push(entry);
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
667 var spans = cont.getElementsByTagName("span");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!note) {
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
678 spans[i].innerHTML =
679 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n + "</a>]";
681 spans[i].setAttribute("data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
694 // Process footnoterefs.
695 for (i=0; i<spans.length; i++) {
696 if (spans[i].className == "footnoteref") {
697 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
698 href = href.match(/#.*/)[0]; // Because IE return full URL.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
708 install: function(toclevels) {
709 var timerId;
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 githooks(5) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>githooks -
743 Hooks used by Git
744 </p>
745 </div>
746 </div>
747 <div id="content">
748 <div class="sect1">
749 <h2 id="_synopsis">SYNOPSIS</h2>
750 <div class="sectionbody">
751 <div class="paragraph"><p>$GIT_DIR/hooks/* (or `git config core.hooksPath`/*)</p></div>
752 </div>
753 </div>
754 <div class="sect1">
755 <h2 id="_description">DESCRIPTION</h2>
756 <div class="sectionbody">
757 <div class="paragraph"><p>Hooks are programs you can place in a hooks directory to trigger
758 actions at certain points in git&#8217;s execution. Hooks that don&#8217;t have
759 the executable bit set are ignored.</p></div>
760 <div class="paragraph"><p>By default the hooks directory is <code>$GIT_DIR/hooks</code>, but that can be
761 changed via the <code>core.hooksPath</code> configuration variable (see
762 <a href="git-config.html">git-config(1)</a>).</p></div>
763 <div class="paragraph"><p>Before Git invokes a hook, it changes its working directory to either
764 $GIT_DIR in a bare repository or the root of the working tree in a non-bare
765 repository. An exception are hooks triggered during a push (<em>pre-receive</em>,
766 <em>update</em>, <em>post-receive</em>, <em>post-update</em>, <em>push-to-checkout</em>) which are always
767 executed in $GIT_DIR.</p></div>
768 <div class="paragraph"><p>Environment variables, such as <code>GIT_DIR</code>, <code>GIT_WORK_TREE</code>, etc., are exported
769 so that Git commands run by the hook can correctly locate the repository. If
770 your hook needs to invoke Git commands in a foreign repository or in a
771 different working tree of the same repository, then it should clear these
772 environment variables so they do not interfere with Git operations at the
773 foreign location. For example:</p></div>
774 <div class="listingblock">
775 <div class="content">
776 <pre><code>local_desc=$(git describe)
777 foreign_desc=$(unset $(git rev-parse --local-env-vars); git -C ../foreign-repo describe)</code></pre>
778 </div></div>
779 <div class="paragraph"><p>Hooks can get their arguments via the environment, command-line
780 arguments, and stdin. See the documentation for each hook below for
781 details.</p></div>
782 <div class="paragraph"><p><code>git init</code> may copy hooks to the new repository, depending on its
783 configuration. See the "TEMPLATE DIRECTORY" section in
784 <a href="git-init.html">git-init(1)</a> for details. When the rest of this document refers
785 to "default hooks" it&#8217;s talking about the default template shipped
786 with Git.</p></div>
787 <div class="paragraph"><p>The currently supported hooks are described below.</p></div>
788 </div>
789 </div>
790 <div class="sect1">
791 <h2 id="_hooks">HOOKS</h2>
792 <div class="sectionbody">
793 <div class="sect2">
794 <h3 id="_applypatch_msg">applypatch-msg</h3>
795 <div class="paragraph"><p>This hook is invoked by <a href="git-am.html">git-am(1)</a>. It takes a single
796 parameter, the name of the file that holds the proposed commit
797 log message. Exiting with a non-zero status causes <code>git am</code> to abort
798 before applying the patch.</p></div>
799 <div class="paragraph"><p>The hook is allowed to edit the message file in place, and can
800 be used to normalize the message into some project standard
801 format. It can also be used to refuse the commit after inspecting
802 the message file.</p></div>
803 <div class="paragraph"><p>The default <em>applypatch-msg</em> hook, when enabled, runs the
804 <em>commit-msg</em> hook, if the latter is enabled.</p></div>
805 </div>
806 <div class="sect2">
807 <h3 id="_pre_applypatch">pre-applypatch</h3>
808 <div class="paragraph"><p>This hook is invoked by <a href="git-am.html">git-am(1)</a>. It takes no parameter, and is
809 invoked after the patch is applied, but before a commit is made.</p></div>
810 <div class="paragraph"><p>If it exits with non-zero status, then the working tree will not be
811 committed after applying the patch.</p></div>
812 <div class="paragraph"><p>It can be used to inspect the current working tree and refuse to
813 make a commit if it does not pass certain tests.</p></div>
814 <div class="paragraph"><p>The default <em>pre-applypatch</em> hook, when enabled, runs the
815 <em>pre-commit</em> hook, if the latter is enabled.</p></div>
816 </div>
817 <div class="sect2">
818 <h3 id="_post_applypatch">post-applypatch</h3>
819 <div class="paragraph"><p>This hook is invoked by <a href="git-am.html">git-am(1)</a>. It takes no parameter,
820 and is invoked after the patch is applied and a commit is made.</p></div>
821 <div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
822 the outcome of <code>git am</code>.</p></div>
823 </div>
824 <div class="sect2">
825 <h3 id="_pre_commit">pre-commit</h3>
826 <div class="paragraph"><p>This hook is invoked by <a href="git-commit.html">git-commit(1)</a>, and can be bypassed
827 with the <code>--no-verify</code> option. It takes no parameters, and is
828 invoked before obtaining the proposed commit log message and
829 making a commit. Exiting with a non-zero status from this script
830 causes the <code>git commit</code> command to abort before creating a commit.</p></div>
831 <div class="paragraph"><p>The default <em>pre-commit</em> hook, when enabled, catches introduction
832 of lines with trailing whitespaces and aborts the commit when
833 such a line is found.</p></div>
834 <div class="paragraph"><p>All the <code>git commit</code> hooks are invoked with the environment
835 variable <code>GIT_EDITOR=:</code> if the command will not bring up an editor
836 to modify the commit message.</p></div>
837 <div class="paragraph"><p>The default <em>pre-commit</em> hook, when enabled&#8212;and with the
838 <code>hooks.allownonascii</code> config option unset or set to false&#8212;prevents
839 the use of non-ASCII filenames.</p></div>
840 </div>
841 <div class="sect2">
842 <h3 id="_pre_merge_commit">pre-merge-commit</h3>
843 <div class="paragraph"><p>This hook is invoked by <a href="git-merge.html">git-merge(1)</a>, and can be bypassed
844 with the <code>--no-verify</code> option. It takes no parameters, and is
845 invoked after the merge has been carried out successfully and before
846 obtaining the proposed commit log message to
847 make a commit. Exiting with a non-zero status from this script
848 causes the <code>git merge</code> command to abort before creating a commit.</p></div>
849 <div class="paragraph"><p>The default <em>pre-merge-commit</em> hook, when enabled, runs the
850 <em>pre-commit</em> hook, if the latter is enabled.</p></div>
851 <div class="paragraph"><p>This hook is invoked with the environment variable
852 <code>GIT_EDITOR=:</code> if the command will not bring up an editor
853 to modify the commit message.</p></div>
854 <div class="paragraph"><p>If the merge cannot be carried out automatically, the conflicts
855 need to be resolved and the result committed separately (see
856 <a href="git-merge.html">git-merge(1)</a>). At that point, this hook will not be executed,
857 but the <em>pre-commit</em> hook will, if it is enabled.</p></div>
858 </div>
859 <div class="sect2">
860 <h3 id="_prepare_commit_msg">prepare-commit-msg</h3>
861 <div class="paragraph"><p>This hook is invoked by <a href="git-commit.html">git-commit(1)</a> right after preparing the
862 default log message, and before the editor is started.</p></div>
863 <div class="paragraph"><p>It takes one to three parameters. The first is the name of the file
864 that contains the commit log message. The second is the source of the commit
865 message, and can be: <code>message</code> (if a <code>-m</code> or <code>-F</code> option was
866 given); <code>template</code> (if a <code>-t</code> option was given or the
867 configuration option <code>commit.template</code> is set); <code>merge</code> (if the
868 commit is a merge or a <code>.git/MERGE_MSG</code> file exists); <code>squash</code>
869 (if a <code>.git/SQUASH_MSG</code> file exists); or <code>commit</code>, followed by
870 a commit object name (if a <code>-c</code>, <code>-C</code> or <code>--amend</code> option was given).</p></div>
871 <div class="paragraph"><p>If the exit status is non-zero, <code>git commit</code> will abort.</p></div>
872 <div class="paragraph"><p>The purpose of the hook is to edit the message file in place, and
873 it is not suppressed by the <code>--no-verify</code> option. A non-zero exit
874 means a failure of the hook and aborts the commit. It should not
875 be used as a replacement for the pre-commit hook.</p></div>
876 <div class="paragraph"><p>The sample <code>prepare-commit-msg</code> hook that comes with Git removes the
877 help message found in the commented portion of the commit template.</p></div>
878 </div>
879 <div class="sect2">
880 <h3 id="_commit_msg">commit-msg</h3>
881 <div class="paragraph"><p>This hook is invoked by <a href="git-commit.html">git-commit(1)</a> and <a href="git-merge.html">git-merge(1)</a>, and can be
882 bypassed with the <code>--no-verify</code> option. It takes a single parameter,
883 the name of the file that holds the proposed commit log message.
884 Exiting with a non-zero status causes the command to abort.</p></div>
885 <div class="paragraph"><p>The hook is allowed to edit the message file in place, and can be used
886 to normalize the message into some project standard format. It
887 can also be used to refuse the commit after inspecting the message
888 file.</p></div>
889 <div class="paragraph"><p>The default <em>commit-msg</em> hook, when enabled, detects duplicate
890 <code>Signed-off-by</code> trailers, and aborts the commit if one is found.</p></div>
891 </div>
892 <div class="sect2">
893 <h3 id="_post_commit">post-commit</h3>
894 <div class="paragraph"><p>This hook is invoked by <a href="git-commit.html">git-commit(1)</a>. It takes no parameters, and is
895 invoked after a commit is made.</p></div>
896 <div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
897 the outcome of <code>git commit</code>.</p></div>
898 </div>
899 <div class="sect2">
900 <h3 id="_pre_rebase">pre-rebase</h3>
901 <div class="paragraph"><p>This hook is called by <a href="git-rebase.html">git-rebase(1)</a> and can be used to prevent a
902 branch from getting rebased. The hook may be called with one or
903 two parameters. The first parameter is the upstream from which
904 the series was forked. The second parameter is the branch being
905 rebased, and is not set when rebasing the current branch.</p></div>
906 </div>
907 <div class="sect2">
908 <h3 id="_post_checkout">post-checkout</h3>
909 <div class="paragraph"><p>This hook is invoked when a <a href="git-checkout.html">git-checkout(1)</a> or
910 <a href="git-switch.html">git-switch(1)</a> is run after having updated the
911 worktree. The hook is given three parameters: the ref of the previous HEAD,
912 the ref of the new HEAD (which may or may not have changed), and a flag
913 indicating whether the checkout was a branch checkout (changing branches,
914 flag=1) or a file checkout (retrieving a file from the index, flag=0).
915 This hook cannot affect the outcome of <code>git switch</code> or <code>git checkout</code>,
916 other than that the hook&#8217;s exit status becomes the exit status of
917 these two commands.</p></div>
918 <div class="paragraph"><p>It is also run after <a href="git-clone.html">git-clone(1)</a>, unless the <code>--no-checkout</code> (<code>-n</code>) option is
919 used. The first parameter given to the hook is the null-ref, the second the
920 ref of the new HEAD and the flag is always 1. Likewise for <code>git worktree add</code>
921 unless <code>--no-checkout</code> is used.</p></div>
922 <div class="paragraph"><p>This hook can be used to perform repository validity checks, auto-display
923 differences from the previous HEAD if different, or set working dir metadata
924 properties.</p></div>
925 </div>
926 <div class="sect2">
927 <h3 id="_post_merge">post-merge</h3>
928 <div class="paragraph"><p>This hook is invoked by <a href="git-merge.html">git-merge(1)</a>, which happens when a <code>git pull</code>
929 is done on a local repository. The hook takes a single parameter, a status
930 flag specifying whether or not the merge being done was a squash merge.
931 This hook cannot affect the outcome of <code>git merge</code> and is not executed,
932 if the merge failed due to conflicts.</p></div>
933 <div class="paragraph"><p>This hook can be used in conjunction with a corresponding pre-commit hook to
934 save and restore any form of metadata associated with the working tree
935 (e.g.: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl
936 for an example of how to do this.</p></div>
937 </div>
938 <div class="sect2">
939 <h3 id="_pre_push">pre-push</h3>
940 <div class="paragraph"><p>This hook is called by <a href="git-push.html">git-push(1)</a> and can be used to prevent
941 a push from taking place. The hook is called with two parameters
942 which provide the name and location of the destination remote, if a
943 named remote is not being used both values will be the same.</p></div>
944 <div class="paragraph"><p>Information about what is to be pushed is provided on the hook&#8217;s standard
945 input with lines of the form:</p></div>
946 <div class="literalblock">
947 <div class="content">
948 <pre><code>&lt;local-ref&gt; SP &lt;local-object-name&gt; SP &lt;remote-ref&gt; SP &lt;remote-object-name&gt; LF</code></pre>
949 </div></div>
950 <div class="paragraph"><p>For instance, if the command <code>git push origin master:foreign</code> were run the
951 hook would receive a line like the following:</p></div>
952 <div class="literalblock">
953 <div class="content">
954 <pre><code>refs/heads/master 67890 refs/heads/foreign 12345</code></pre>
955 </div></div>
956 <div class="paragraph"><p>although the full object name would be supplied. If the foreign ref does not
957 yet exist the <code>&lt;remote-object-name&gt;</code> will be the all-zeroes object name. If a
958 ref is to be deleted, the <code>&lt;local-ref&gt;</code> will be supplied as <code>(delete)</code> and the
959 <code>&lt;local-object-name&gt;</code> will be the all-zeroes object name. If the local commit
960 was specified by something other than a name which could be expanded (such as
961 <code>HEAD~</code>, or an object name) it will be supplied as it was originally given.</p></div>
962 <div class="paragraph"><p>If this hook exits with a non-zero status, <code>git push</code> will abort without
963 pushing anything. Information about why the push is rejected may be sent
964 to the user by writing to standard error.</p></div>
965 </div>
966 <div class="sect2">
967 <h3 id="pre-receive">pre-receive</h3>
968 <div class="paragraph"><p>This hook is invoked by <a href="git-receive-pack.html">git-receive-pack(1)</a> when it reacts to
969 <code>git push</code> and updates reference(s) in its repository.
970 Just before starting to update refs on the remote repository, the
971 pre-receive hook is invoked. Its exit status determines the success
972 or failure of the update.</p></div>
973 <div class="paragraph"><p>This hook executes once for the receive operation. It takes no
974 arguments, but for each ref to be updated it receives on standard
975 input a line of the format:</p></div>
976 <div class="literalblock">
977 <div class="content">
978 <pre><code>&lt;old-oid&gt; SP &lt;new-oid&gt; SP &lt;ref-name&gt; LF</code></pre>
979 </div></div>
980 <div class="paragraph"><p>where <code>&lt;old-oid&gt;</code> is the old object name stored in the ref,
981 <code>&lt;new-oid&gt;</code> is the new object name to be stored in the ref and
982 <code>&lt;ref-name&gt;</code> is the full name of the ref.
983 When creating a new ref, <code>&lt;old-oid&gt;</code> is the all-zeroes object name.</p></div>
984 <div class="paragraph"><p>If the hook exits with non-zero status, none of the refs will be
985 updated. If the hook exits with zero, updating of individual refs can
986 still be prevented by the <a href="#update"><em>update</em></a> hook.</p></div>
987 <div class="paragraph"><p>Both standard output and standard error output are forwarded to
988 <code>git send-pack</code> on the other end, so you can simply <code>echo</code> messages
989 for the user.</p></div>
990 <div class="paragraph"><p>The number of push options given on the command line of
991 <code>git push --push-option=...</code> can be read from the environment
992 variable <code>GIT_PUSH_OPTION_COUNT</code>, and the options themselves are
993 found in <code>GIT_PUSH_OPTION_0</code>, <code>GIT_PUSH_OPTION_1</code>,&#8230;
994 If it is negotiated to not use the push options phase, the
995 environment variables will not be set. If the client selects
996 to use push options, but doesn&#8217;t transmit any, the count variable
997 will be set to zero, <code>GIT_PUSH_OPTION_COUNT=0</code>.</p></div>
998 <div class="paragraph"><p>See the section on "Quarantine Environment" in
999 <a href="git-receive-pack.html">git-receive-pack(1)</a> for some caveats.</p></div>
1000 </div>
1001 <div class="sect2">
1002 <h3 id="update">update</h3>
1003 <div class="paragraph"><p>This hook is invoked by <a href="git-receive-pack.html">git-receive-pack(1)</a> when it reacts to
1004 <code>git push</code> and updates reference(s) in its repository.
1005 Just before updating the ref on the remote repository, the update hook
1006 is invoked. Its exit status determines the success or failure of
1007 the ref update.</p></div>
1008 <div class="paragraph"><p>The hook executes once for each ref to be updated, and takes
1009 three parameters:</p></div>
1010 <div class="ulist"><ul>
1011 <li>
1013 the name of the ref being updated,
1014 </p>
1015 </li>
1016 <li>
1018 the old object name stored in the ref,
1019 </p>
1020 </li>
1021 <li>
1023 and the new object name to be stored in the ref.
1024 </p>
1025 </li>
1026 </ul></div>
1027 <div class="paragraph"><p>A zero exit from the update hook allows the ref to be updated.
1028 Exiting with a non-zero status prevents <code>git receive-pack</code>
1029 from updating that ref.</p></div>
1030 <div class="paragraph"><p>This hook can be used to prevent <em>forced</em> update on certain refs by
1031 making sure that the object name is a commit object that is a
1032 descendant of the commit object named by the old object name.
1033 That is, to enforce a "fast-forward only" policy.</p></div>
1034 <div class="paragraph"><p>It could also be used to log the old..new status. However, it
1035 does not know the entire set of branches, so it would end up
1036 firing one e-mail per ref when used naively, though. The
1037 <a href="#post-receive"><em>post-receive</em></a> hook is more suited to that.</p></div>
1038 <div class="paragraph"><p>In an environment that restricts the users' access only to git
1039 commands over the wire, this hook can be used to implement access
1040 control without relying on filesystem ownership and group
1041 membership. See <a href="git-shell.html">git-shell(1)</a> for how you might use the login
1042 shell to restrict the user&#8217;s access to only git commands.</p></div>
1043 <div class="paragraph"><p>Both standard output and standard error output are forwarded to
1044 <code>git send-pack</code> on the other end, so you can simply <code>echo</code> messages
1045 for the user.</p></div>
1046 <div class="paragraph"><p>The default <em>update</em> hook, when enabled&#8212;and with
1047 <code>hooks.allowunannotated</code> config option unset or set to false&#8212;prevents
1048 unannotated tags from being pushed.</p></div>
1049 </div>
1050 <div class="sect2">
1051 <h3 id="proc-receive">proc-receive</h3>
1052 <div class="paragraph"><p>This hook is invoked by <a href="git-receive-pack.html">git-receive-pack(1)</a>. If the server has
1053 set the multi-valued config variable <code>receive.procReceiveRefs</code>, and the
1054 commands sent to <em>receive-pack</em> have matching reference names, these
1055 commands will be executed by this hook, instead of by the internal
1056 <code>execute_commands()</code> function. This hook is responsible for updating
1057 the relevant references and reporting the results back to <em>receive-pack</em>.</p></div>
1058 <div class="paragraph"><p>This hook executes once for the receive operation. It takes no
1059 arguments, but uses a pkt-line format protocol to communicate with
1060 <em>receive-pack</em> to read commands, push-options and send results. In the
1061 following example for the protocol, the letter <em>S</em> stands for
1062 <em>receive-pack</em> and the letter <em>H</em> stands for this hook.</p></div>
1063 <div class="literalblock">
1064 <div class="content">
1065 <pre><code># Version and features negotiation.
1066 S: PKT-LINE(version=1\0push-options atomic...)
1067 S: flush-pkt
1068 H: PKT-LINE(version=1\0push-options...)
1069 H: flush-pkt</code></pre>
1070 </div></div>
1071 <div class="literalblock">
1072 <div class="content">
1073 <pre><code># Send commands from server to the hook.
1074 S: PKT-LINE(&lt;old-oid&gt; &lt;new-oid&gt; &lt;ref&gt;)
1075 S: ... ...
1076 S: flush-pkt
1077 # Send push-options only if the 'push-options' feature is enabled.
1078 S: PKT-LINE(push-option)
1079 S: ... ...
1080 S: flush-pkt</code></pre>
1081 </div></div>
1082 <div class="literalblock">
1083 <div class="content">
1084 <pre><code># Receive results from the hook.
1085 # OK, run this command successfully.
1086 H: PKT-LINE(ok &lt;ref&gt;)
1087 # NO, I reject it.
1088 H: PKT-LINE(ng &lt;ref&gt; &lt;reason&gt;)
1089 # Fall through, let 'receive-pack' execute it.
1090 H: PKT-LINE(ok &lt;ref&gt;)
1091 H: PKT-LINE(option fall-through)
1092 # OK, but has an alternate reference. The alternate reference name
1093 # and other status can be given in option directives.
1094 H: PKT-LINE(ok &lt;ref&gt;)
1095 H: PKT-LINE(option refname &lt;refname&gt;)
1096 H: PKT-LINE(option old-oid &lt;old-oid&gt;)
1097 H: PKT-LINE(option new-oid &lt;new-oid&gt;)
1098 H: PKT-LINE(option forced-update)
1099 H: ... ...
1100 H: flush-pkt</code></pre>
1101 </div></div>
1102 <div class="paragraph"><p>Each command for the <em>proc-receive</em> hook may point to a pseudo-reference
1103 and always has a zero-old as its old-oid, while the <em>proc-receive</em> hook
1104 may update an alternate reference and the alternate reference may exist
1105 already with a non-zero old-oid. For this case, this hook will use
1106 "option" directives to report extended attributes for the reference given
1107 by the leading "ok" directive.</p></div>
1108 <div class="paragraph"><p>The report of the commands of this hook should have the same order as
1109 the input. The exit status of the <em>proc-receive</em> hook only determines
1110 the success or failure of the group of commands sent to it, unless
1111 atomic push is in use.</p></div>
1112 </div>
1113 <div class="sect2">
1114 <h3 id="post-receive">post-receive</h3>
1115 <div class="paragraph"><p>This hook is invoked by <a href="git-receive-pack.html">git-receive-pack(1)</a> when it reacts to
1116 <code>git push</code> and updates reference(s) in its repository.
1117 It executes on the remote repository once after all the refs have
1118 been updated.</p></div>
1119 <div class="paragraph"><p>This hook executes once for the receive operation. It takes no
1120 arguments, but gets the same information as the
1121 <a href="#pre-receive"><em>pre-receive</em></a>
1122 hook does on its standard input.</p></div>
1123 <div class="paragraph"><p>This hook does not affect the outcome of <code>git receive-pack</code>, as it
1124 is called after the real work is done.</p></div>
1125 <div class="paragraph"><p>This supersedes the <a href="#post-update"><em>post-update</em></a> hook in that it gets
1126 both old and new values of all the refs in addition to their
1127 names.</p></div>
1128 <div class="paragraph"><p>Both standard output and standard error output are forwarded to
1129 <code>git send-pack</code> on the other end, so you can simply <code>echo</code> messages
1130 for the user.</p></div>
1131 <div class="paragraph"><p>The default <em>post-receive</em> hook is empty, but there is
1132 a sample script <code>post-receive-email</code> provided in the <code>contrib/hooks</code>
1133 directory in Git distribution, which implements sending commit
1134 emails.</p></div>
1135 <div class="paragraph"><p>The number of push options given on the command line of
1136 <code>git push --push-option=...</code> can be read from the environment
1137 variable <code>GIT_PUSH_OPTION_COUNT</code>, and the options themselves are
1138 found in <code>GIT_PUSH_OPTION_0</code>, <code>GIT_PUSH_OPTION_1</code>,&#8230;
1139 If it is negotiated to not use the push options phase, the
1140 environment variables will not be set. If the client selects
1141 to use push options, but doesn&#8217;t transmit any, the count variable
1142 will be set to zero, <code>GIT_PUSH_OPTION_COUNT=0</code>.</p></div>
1143 </div>
1144 <div class="sect2">
1145 <h3 id="post-update">post-update</h3>
1146 <div class="paragraph"><p>This hook is invoked by <a href="git-receive-pack.html">git-receive-pack(1)</a> when it reacts to
1147 <code>git push</code> and updates reference(s) in its repository.
1148 It executes on the remote repository once after all the refs have
1149 been updated.</p></div>
1150 <div class="paragraph"><p>It takes a variable number of parameters, each of which is the
1151 name of ref that was actually updated.</p></div>
1152 <div class="paragraph"><p>This hook is meant primarily for notification, and cannot affect
1153 the outcome of <code>git receive-pack</code>.</p></div>
1154 <div class="paragraph"><p>The <em>post-update</em> hook can tell what are the heads that were pushed,
1155 but it does not know what their original and updated values are,
1156 so it is a poor place to do log old..new. The
1157 <a href="#post-receive"><em>post-receive</em></a> hook does get both original and
1158 updated values of the refs. You might consider it instead if you need
1159 them.</p></div>
1160 <div class="paragraph"><p>When enabled, the default <em>post-update</em> hook runs
1161 <code>git update-server-info</code> to keep the information used by dumb
1162 transports (e.g., HTTP) up to date. If you are publishing
1163 a Git repository that is accessible via HTTP, you should
1164 probably enable this hook.</p></div>
1165 <div class="paragraph"><p>Both standard output and standard error output are forwarded to
1166 <code>git send-pack</code> on the other end, so you can simply <code>echo</code> messages
1167 for the user.</p></div>
1168 </div>
1169 <div class="sect2">
1170 <h3 id="_reference_transaction">reference-transaction</h3>
1171 <div class="paragraph"><p>This hook is invoked by any Git command that performs reference
1172 updates. It executes whenever a reference transaction is prepared,
1173 committed or aborted and may thus get called multiple times. The hook
1174 does not cover symbolic references (but that may change in the future).</p></div>
1175 <div class="paragraph"><p>The hook takes exactly one argument, which is the current state the
1176 given reference transaction is in:</p></div>
1177 <div class="ulist"><ul>
1178 <li>
1180 "prepared": All reference updates have been queued to the
1181 transaction and references were locked on disk.
1182 </p>
1183 </li>
1184 <li>
1186 "committed": The reference transaction was committed and all
1187 references now have their respective new value.
1188 </p>
1189 </li>
1190 <li>
1192 "aborted": The reference transaction was aborted, no changes
1193 were performed and the locks have been released.
1194 </p>
1195 </li>
1196 </ul></div>
1197 <div class="paragraph"><p>For each reference update that was added to the transaction, the hook
1198 receives on standard input a line of the format:</p></div>
1199 <div class="literalblock">
1200 <div class="content">
1201 <pre><code>&lt;old-oid&gt; SP &lt;new-oid&gt; SP &lt;ref-name&gt; LF</code></pre>
1202 </div></div>
1203 <div class="paragraph"><p>where <code>&lt;old-oid&gt;</code> is the old object name passed into the reference
1204 transaction, <code>&lt;new-oid&gt;</code> is the new object name to be stored in the
1205 ref and <code>&lt;ref-name&gt;</code> is the full name of the ref. When force updating
1206 the reference regardless of its current value or when the reference is
1207 to be created anew, <code>&lt;old-oid&gt;</code> is the all-zeroes object name. To
1208 distinguish these cases, you can inspect the current value of
1209 <code>&lt;ref-name&gt;</code> via <code>git rev-parse</code>.</p></div>
1210 <div class="paragraph"><p>The exit status of the hook is ignored for any state except for the
1211 "prepared" state. In the "prepared" state, a non-zero exit status will
1212 cause the transaction to be aborted. The hook will not be called with
1213 "aborted" state in that case.</p></div>
1214 </div>
1215 <div class="sect2">
1216 <h3 id="_push_to_checkout">push-to-checkout</h3>
1217 <div class="paragraph"><p>This hook is invoked by <a href="git-receive-pack.html">git-receive-pack(1)</a> when it reacts to
1218 <code>git push</code> and updates reference(s) in its repository, and when
1219 the push tries to update the branch that is currently checked out
1220 and the <code>receive.denyCurrentBranch</code> configuration variable is set to
1221 <code>updateInstead</code>. Such a push by default is refused if the working
1222 tree and the index of the remote repository has any difference from
1223 the currently checked out commit; when both the working tree and the
1224 index match the current commit, they are updated to match the newly
1225 pushed tip of the branch. This hook is to be used to override the
1226 default behaviour.</p></div>
1227 <div class="paragraph"><p>The hook receives the commit with which the tip of the current
1228 branch is going to be updated. It can exit with a non-zero status
1229 to refuse the push (when it does so, it must not modify the index or
1230 the working tree). Or it can make any necessary changes to the
1231 working tree and to the index to bring them to the desired state
1232 when the tip of the current branch is updated to the new commit, and
1233 exit with a zero status.</p></div>
1234 <div class="paragraph"><p>For example, the hook can simply run <code>git read-tree -u -m HEAD "$1"</code>
1235 in order to emulate <code>git fetch</code> that is run in the reverse direction
1236 with <code>git push</code>, as the two-tree form of <code>git read-tree -u -m</code> is
1237 essentially the same as <code>git switch</code> or <code>git checkout</code>
1238 that switches branches while
1239 keeping the local changes in the working tree that do not interfere
1240 with the difference between the branches.</p></div>
1241 </div>
1242 <div class="sect2">
1243 <h3 id="_pre_auto_gc">pre-auto-gc</h3>
1244 <div class="paragraph"><p>This hook is invoked by <code>git gc --auto</code> (see <a href="git-gc.html">git-gc(1)</a>). It
1245 takes no parameter, and exiting with non-zero status from this script
1246 causes the <code>git gc --auto</code> to abort.</p></div>
1247 </div>
1248 <div class="sect2">
1249 <h3 id="_post_rewrite">post-rewrite</h3>
1250 <div class="paragraph"><p>This hook is invoked by commands that rewrite commits
1251 (<a href="git-commit.html">git-commit(1)</a> when called with <code>--amend</code> and
1252 <a href="git-rebase.html">git-rebase(1)</a>; however, full-history (re)writing tools like
1253 <a href="git-fast-import.html">git-fast-import(1)</a> or
1254 <a href="https://github.com/newren/git-filter-repo">git-filter-repo</a> typically
1255 do not call it!). Its first argument denotes the command it was
1256 invoked by: currently one of <code>amend</code> or <code>rebase</code>. Further
1257 command-dependent arguments may be passed in the future.</p></div>
1258 <div class="paragraph"><p>The hook receives a list of the rewritten commits on stdin, in the
1259 format</p></div>
1260 <div class="literalblock">
1261 <div class="content">
1262 <pre><code>&lt;old-object-name&gt; SP &lt;new-object-name&gt; [ SP &lt;extra-info&gt; ] LF</code></pre>
1263 </div></div>
1264 <div class="paragraph"><p>The <em>extra-info</em> is again command-dependent. If it is empty, the
1265 preceding SP is also omitted. Currently, no commands pass any
1266 <em>extra-info</em>.</p></div>
1267 <div class="paragraph"><p>The hook always runs after the automatic note copying (see
1268 "notes.rewrite.&lt;command&gt;" in <a href="git-config.html">git-config(1)</a>) has happened, and
1269 thus has access to these notes.</p></div>
1270 <div class="paragraph"><p>The following command-specific comments apply:</p></div>
1271 <div class="dlist"><dl>
1272 <dt class="hdlist1">
1273 rebase
1274 </dt>
1275 <dd>
1277 For the <em>squash</em> and <em>fixup</em> operation, all commits that were
1278 squashed are listed as being rewritten to the squashed commit.
1279 This means that there will be several lines sharing the same
1280 <em>new-object-name</em>.
1281 </p>
1282 <div class="paragraph"><p>The commits are guaranteed to be listed in the order that they were
1283 processed by rebase.</p></div>
1284 </dd>
1285 </dl></div>
1286 </div>
1287 <div class="sect2">
1288 <h3 id="_sendemail_validate">sendemail-validate</h3>
1289 <div class="paragraph"><p>This hook is invoked by <a href="git-send-email.html">git-send-email(1)</a>.</p></div>
1290 <div class="paragraph"><p>It takes these command line arguments. They are,
1291 1. the name of the file which holds the contents of the email to be sent.
1292 2. The name of the file which holds the SMTP headers of the email.</p></div>
1293 <div class="paragraph"><p>The SMTP headers are passed in the exact same way as they are passed to the
1294 user&#8217;s Mail Transport Agent (MTA). In effect, the email given to the user&#8217;s
1295 MTA, is the contents of $2 followed by the contents of $1.</p></div>
1296 <div class="paragraph"><p>An example of a few common headers is shown below. Take notice of the
1297 capitalization and multi-line tab structure.</p></div>
1298 <div class="literalblock">
1299 <div class="content">
1300 <pre><code>From: Example &lt;from@example.com&gt;
1301 To: to@example.com
1302 Cc: cc@example.com,
1303 A &lt;author@example.com&gt;,
1304 One &lt;one@example.com&gt;,
1305 two@example.com
1306 Subject: PATCH-STRING</code></pre>
1307 </div></div>
1308 <div class="paragraph"><p>Exiting with a non-zero status causes <code>git send-email</code> to abort
1309 before sending any e-mails.</p></div>
1310 <div class="paragraph"><p>The following environment variables are set when executing the hook.</p></div>
1311 <div class="dlist"><dl>
1312 <dt class="hdlist1">
1313 <code>GIT_SENDEMAIL_FILE_COUNTER</code>
1314 </dt>
1315 <dd>
1317 A 1-based counter incremented by one for every file holding an e-mail
1318 to be sent (excluding any FIFOs). This counter does not follow the
1319 patch series counter scheme. It will always start at 1 and will end at
1320 GIT_SENDEMAIL_FILE_TOTAL.
1321 </p>
1322 </dd>
1323 <dt class="hdlist1">
1324 <code>GIT_SENDEMAIL_FILE_TOTAL</code>
1325 </dt>
1326 <dd>
1328 The total number of files that will be sent (excluding any FIFOs). This
1329 counter does not follow the patch series counter scheme. It will always
1330 be equal to the number of files being sent, whether there is a cover
1331 letter or not.
1332 </p>
1333 </dd>
1334 </dl></div>
1335 <div class="paragraph"><p>These variables may for instance be used to validate patch series.</p></div>
1336 <div class="paragraph"><p>The sample <code>sendemail-validate</code> hook that comes with Git checks that all sent
1337 patches (excluding the cover letter) can be applied on top of the upstream
1338 repository default branch without conflicts. Some placeholders are left for
1339 additional validation steps to be performed after all patches of a given series
1340 have been applied.</p></div>
1341 </div>
1342 <div class="sect2">
1343 <h3 id="_fsmonitor_watchman">fsmonitor-watchman</h3>
1344 <div class="paragraph"><p>This hook is invoked when the configuration option <code>core.fsmonitor</code> is
1345 set to <code>.git/hooks/fsmonitor-watchman</code> or <code>.git/hooks/fsmonitor-watchmanv2</code>
1346 depending on the version of the hook to use.</p></div>
1347 <div class="paragraph"><p>Version 1 takes two arguments, a version (1) and the time in elapsed
1348 nanoseconds since midnight, January 1, 1970.</p></div>
1349 <div class="paragraph"><p>Version 2 takes two arguments, a version (2) and a token that is used
1350 for identifying changes since the token. For watchman this would be
1351 a clock id. This version must output to stdout the new token followed
1352 by a NUL before the list of files.</p></div>
1353 <div class="paragraph"><p>The hook should output to stdout the list of all files in the working
1354 directory that may have changed since the requested time. The logic
1355 should be inclusive so that it does not miss any potential changes.
1356 The paths should be relative to the root of the working directory
1357 and be separated by a single NUL.</p></div>
1358 <div class="paragraph"><p>It is OK to include files which have not actually changed. All changes
1359 including newly-created and deleted files should be included. When
1360 files are renamed, both the old and the new name should be included.</p></div>
1361 <div class="paragraph"><p>Git will limit what files it checks for changes as well as which
1362 directories are checked for untracked files based on the path names
1363 given.</p></div>
1364 <div class="paragraph"><p>An optimized way to tell git "all files have changed" is to return
1365 the filename <code>/</code>.</p></div>
1366 <div class="paragraph"><p>The exit status determines whether git will use the data from the
1367 hook to limit its search. On error, it will fall back to verifying
1368 all files and folders.</p></div>
1369 </div>
1370 <div class="sect2">
1371 <h3 id="_p4_changelist">p4-changelist</h3>
1372 <div class="paragraph"><p>This hook is invoked by <code>git-p4 submit</code>.</p></div>
1373 <div class="paragraph"><p>The <code>p4-changelist</code> hook is executed after the changelist
1374 message has been edited by the user. It can be bypassed with the
1375 <code>--no-verify</code> option. It takes a single parameter, the name
1376 of the file that holds the proposed changelist text. Exiting
1377 with a non-zero status causes the command to abort.</p></div>
1378 <div class="paragraph"><p>The hook is allowed to edit the changelist file and can be used
1379 to normalize the text into some project standard format. It can
1380 also be used to refuse the Submit after inspect the message file.</p></div>
1381 <div class="paragraph"><p>Run <code>git-p4 submit --help</code> for details.</p></div>
1382 </div>
1383 <div class="sect2">
1384 <h3 id="_p4_prepare_changelist">p4-prepare-changelist</h3>
1385 <div class="paragraph"><p>This hook is invoked by <code>git-p4 submit</code>.</p></div>
1386 <div class="paragraph"><p>The <code>p4-prepare-changelist</code> hook is executed right after preparing
1387 the default changelist message and before the editor is started.
1388 It takes one parameter, the name of the file that contains the
1389 changelist text. Exiting with a non-zero status from the script
1390 will abort the process.</p></div>
1391 <div class="paragraph"><p>The purpose of the hook is to edit the message file in place,
1392 and it is not suppressed by the <code>--no-verify</code> option. This hook
1393 is called even if <code>--prepare-p4-only</code> is set.</p></div>
1394 <div class="paragraph"><p>Run <code>git-p4 submit --help</code> for details.</p></div>
1395 </div>
1396 <div class="sect2">
1397 <h3 id="_p4_post_changelist">p4-post-changelist</h3>
1398 <div class="paragraph"><p>This hook is invoked by <code>git-p4 submit</code>.</p></div>
1399 <div class="paragraph"><p>The <code>p4-post-changelist</code> hook is invoked after the submit has
1400 successfully occurred in P4. It takes no parameters and is meant
1401 primarily for notification and cannot affect the outcome of the
1402 git p4 submit action.</p></div>
1403 <div class="paragraph"><p>Run <code>git-p4 submit --help</code> for details.</p></div>
1404 </div>
1405 <div class="sect2">
1406 <h3 id="_p4_pre_submit">p4-pre-submit</h3>
1407 <div class="paragraph"><p>This hook is invoked by <code>git-p4 submit</code>. It takes no parameters and nothing
1408 from standard input. Exiting with non-zero status from this script prevent
1409 <code>git-p4 submit</code> from launching. It can be bypassed with the <code>--no-verify</code>
1410 command line option. Run <code>git-p4 submit --help</code> for details.</p></div>
1411 </div>
1412 <div class="sect2">
1413 <h3 id="_post_index_change">post-index-change</h3>
1414 <div class="paragraph"><p>This hook is invoked when the index is written in read-cache.c
1415 do_write_locked_index.</p></div>
1416 <div class="paragraph"><p>The first parameter passed to the hook is the indicator for the
1417 working directory being updated. "1" meaning working directory
1418 was updated or "0" when the working directory was not updated.</p></div>
1419 <div class="paragraph"><p>The second parameter passed to the hook is the indicator for whether
1420 or not the index was updated and the skip-worktree bit could have
1421 changed. "1" meaning skip-worktree bits could have been updated
1422 and "0" meaning they were not.</p></div>
1423 <div class="paragraph"><p>Only one parameter should be set to "1" when the hook runs. The hook
1424 running passing "1", "1" should not be possible.</p></div>
1425 </div>
1426 </div>
1427 </div>
1428 <div class="sect1">
1429 <h2 id="_see_also">SEE ALSO</h2>
1430 <div class="sectionbody">
1431 <div class="paragraph"><p><a href="git-hook.html">git-hook(1)</a></p></div>
1432 </div>
1433 </div>
1434 <div class="sect1">
1435 <h2 id="_git">GIT</h2>
1436 <div class="sectionbody">
1437 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1438 </div>
1439 </div>
1440 </div>
1441 <div id="footnotes"><hr /></div>
1442 <div id="footer">
1443 <div id="footer-text">
1444 Last updated
1445 2024-04-10 12:46:30 PDT
1446 </div>
1447 </div>
1448 </body>
1449 </html>