Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 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" /> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 8.2.5" /> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 7 | <style type="text/css"> |
| 8 | /* Debug borders */ |
| 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
| 10 | /* |
| 11 | border: 1px solid red; |
| 12 | */ |
| 13 | } |
| 14 | |
| 15 | body { |
| 16 | margin: 1em 5% 1em 5%; |
| 17 | } |
| 18 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 19 | a { |
| 20 | color: blue; |
| 21 | text-decoration: underline; |
| 22 | } |
| 23 | a:visited { |
| 24 | color: fuchsia; |
| 25 | } |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 26 | |
| 27 | em { |
| 28 | font-style: italic; |
| 29 | } |
| 30 | |
| 31 | strong { |
| 32 | font-weight: bold; |
| 33 | } |
| 34 | |
| 35 | tt { |
| 36 | color: navy; |
| 37 | } |
| 38 | |
| 39 | h1, h2, h3, h4, h5, h6 { |
| 40 | color: #527bbd; |
| 41 | font-family: sans-serif; |
| 42 | margin-top: 1.2em; |
| 43 | margin-bottom: 0.5em; |
| 44 | line-height: 1.3; |
| 45 | } |
| 46 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 47 | h1, h2, h3 { |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 48 | border-bottom: 2px solid silver; |
| 49 | } |
| 50 | h2 { |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 51 | padding-top: 0.5em; |
| 52 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 53 | h3 { |
| 54 | float: left; |
| 55 | } |
| 56 | h3 + * { |
| 57 | clear: left; |
| 58 | } |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 59 | |
| 60 | div.sectionbody { |
| 61 | font-family: serif; |
| 62 | margin-left: 0; |
| 63 | } |
| 64 | |
| 65 | hr { |
| 66 | border: 1px solid silver; |
| 67 | } |
| 68 | |
| 69 | p { |
| 70 | margin-top: 0.5em; |
| 71 | margin-bottom: 0.5em; |
| 72 | } |
| 73 | |
| 74 | pre { |
| 75 | padding: 0; |
| 76 | margin: 0; |
| 77 | } |
| 78 | |
| 79 | span#author { |
| 80 | color: #527bbd; |
| 81 | font-family: sans-serif; |
| 82 | font-weight: bold; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 83 | font-size: 1.1em; |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 84 | } |
| 85 | span#email { |
| 86 | } |
| 87 | span#revision { |
| 88 | font-family: sans-serif; |
| 89 | } |
| 90 | |
| 91 | div#footer { |
| 92 | font-family: sans-serif; |
| 93 | font-size: small; |
| 94 | border-top: 2px solid silver; |
| 95 | padding-top: 0.5em; |
| 96 | margin-top: 4.0em; |
| 97 | } |
| 98 | div#footer-text { |
| 99 | float: left; |
| 100 | padding-bottom: 0.5em; |
| 101 | } |
| 102 | div#footer-badges { |
| 103 | float: right; |
| 104 | padding-bottom: 0.5em; |
| 105 | } |
| 106 | |
| 107 | div#preamble, |
| 108 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 109 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 110 | div.admonitionblock { |
| 111 | margin-right: 10%; |
| 112 | margin-top: 1.5em; |
| 113 | margin-bottom: 1.5em; |
| 114 | } |
| 115 | div.admonitionblock { |
| 116 | margin-top: 2.5em; |
| 117 | margin-bottom: 2.5em; |
| 118 | } |
| 119 | |
| 120 | div.content { /* Block element content. */ |
| 121 | padding: 0; |
| 122 | } |
| 123 | |
| 124 | /* Block element titles. */ |
| 125 | div.title, caption.title { |
| 126 | font-family: sans-serif; |
| 127 | font-weight: bold; |
| 128 | text-align: left; |
| 129 | margin-top: 1.0em; |
| 130 | margin-bottom: 0.5em; |
| 131 | } |
| 132 | div.title + * { |
| 133 | margin-top: 0; |
| 134 | } |
| 135 | |
| 136 | td div.title:first-child { |
| 137 | margin-top: 0.0em; |
| 138 | } |
| 139 | div.content div.title:first-child { |
| 140 | margin-top: 0.0em; |
| 141 | } |
| 142 | div.content + div.title { |
| 143 | margin-top: 0.0em; |
| 144 | } |
| 145 | |
| 146 | div.sidebarblock > div.content { |
| 147 | background: #ffffee; |
| 148 | border: 1px solid silver; |
| 149 | padding: 0.5em; |
| 150 | } |
| 151 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 152 | div.listingblock { |
| 153 | margin-right: 0%; |
| 154 | } |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 155 | div.listingblock > div.content { |
| 156 | border: 1px solid silver; |
| 157 | background: #f4f4f4; |
| 158 | padding: 0.5em; |
| 159 | } |
| 160 | |
| 161 | div.quoteblock > div.content { |
| 162 | padding-left: 2.0em; |
| 163 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 164 | |
| 165 | div.attribution { |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 166 | text-align: right; |
| 167 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 168 | div.verseblock + div.attribution { |
| 169 | text-align: left; |
| 170 | } |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 171 | |
| 172 | div.admonitionblock .icon { |
| 173 | vertical-align: top; |
| 174 | font-size: 1.1em; |
| 175 | font-weight: bold; |
| 176 | text-decoration: underline; |
| 177 | color: #527bbd; |
| 178 | padding-right: 0.5em; |
| 179 | } |
| 180 | div.admonitionblock td.content { |
| 181 | padding-left: 0.5em; |
| 182 | border-left: 2px solid silver; |
| 183 | } |
| 184 | |
| 185 | div.exampleblock > div.content { |
| 186 | border-left: 2px solid silver; |
| 187 | padding: 0.5em; |
| 188 | } |
| 189 | |
| 190 | div.verseblock div.content { |
| 191 | white-space: pre; |
| 192 | } |
| 193 | |
| 194 | div.imageblock div.content { padding-left: 0; } |
| 195 | div.imageblock img { border: 1px solid silver; } |
| 196 | span.image img { border-style: none; } |
| 197 | |
| 198 | dl { |
| 199 | margin-top: 0.8em; |
| 200 | margin-bottom: 0.8em; |
| 201 | } |
| 202 | dt { |
| 203 | margin-top: 0.5em; |
| 204 | margin-bottom: 0; |
| 205 | font-style: italic; |
| 206 | } |
| 207 | dd > *:first-child { |
| 208 | margin-top: 0; |
| 209 | } |
| 210 | |
| 211 | ul, ol { |
| 212 | list-style-position: outside; |
| 213 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 214 | div.olist2 ol { |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 215 | list-style-type: lower-alpha; |
| 216 | } |
| 217 | |
| 218 | div.tableblock > table { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 219 | border: 3px solid #527bbd; |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 220 | } |
| 221 | thead { |
| 222 | font-family: sans-serif; |
| 223 | font-weight: bold; |
| 224 | } |
| 225 | tfoot { |
| 226 | font-weight: bold; |
| 227 | } |
| 228 | |
| 229 | div.hlist { |
| 230 | margin-top: 0.8em; |
| 231 | margin-bottom: 0.8em; |
| 232 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 233 | div.hlist td { |
| 234 | padding-bottom: 5px; |
| 235 | } |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 236 | td.hlist1 { |
| 237 | vertical-align: top; |
| 238 | font-style: italic; |
| 239 | padding-right: 0.8em; |
| 240 | } |
| 241 | td.hlist2 { |
| 242 | vertical-align: top; |
| 243 | } |
| 244 | |
| 245 | @media print { |
| 246 | div#footer-badges { display: none; } |
| 247 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 248 | |
| 249 | div#toctitle { |
| 250 | color: #527bbd; |
| 251 | font-family: sans-serif; |
| 252 | font-size: 1.1em; |
| 253 | font-weight: bold; |
| 254 | margin-top: 1.0em; |
| 255 | margin-bottom: 0.1em; |
| 256 | } |
| 257 | |
| 258 | div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
| 259 | margin-top: 0; |
| 260 | margin-bottom: 0; |
| 261 | } |
| 262 | div.toclevel2 { |
| 263 | margin-left: 2em; |
| 264 | font-size: 0.9em; |
| 265 | } |
| 266 | div.toclevel3 { |
| 267 | margin-left: 4em; |
| 268 | font-size: 0.9em; |
| 269 | } |
| 270 | div.toclevel4 { |
| 271 | margin-left: 6em; |
| 272 | font-size: 0.9em; |
| 273 | } |
| 274 | include1::./stylesheets/xhtml11-manpage.css[] |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 275 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 276 | |
| 277 | div.sidebar-content { |
| 278 | background: #ffffee; |
| 279 | border: 1px solid silver; |
| 280 | padding: 0.5em; |
| 281 | } |
| 282 | div.sidebar-title, div.image-title { |
| 283 | font-family: sans-serif; |
| 284 | font-weight: bold; |
| 285 | margin-top: 0.0em; |
| 286 | margin-bottom: 0.5em; |
| 287 | } |
| 288 | |
| 289 | div.listingblock div.content { |
| 290 | border: 1px solid silver; |
| 291 | background: #f4f4f4; |
| 292 | padding: 0.5em; |
| 293 | } |
| 294 | |
| 295 | div.quoteblock-content { |
| 296 | padding-left: 2.0em; |
| 297 | } |
| 298 | |
| 299 | div.exampleblock-content { |
| 300 | border-left: 2px solid silver; |
| 301 | padding-left: 0.5em; |
| 302 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 303 | |
| 304 | /* IE6 sets dynamically generated links as visited. */ |
| 305 | div#toc a:visited { color: blue; } |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 306 | </style> |
| 307 | <title>githooks(5)</title> |
| 308 | </head> |
| 309 | <body> |
| 310 | <div id="header"> |
| 311 | <h1> |
| 312 | githooks(5) Manual Page |
| 313 | </h1> |
| 314 | <h2>NAME</h2> |
| 315 | <div class="sectionbody"> |
| 316 | <p>githooks - |
| 317 | Hooks used by git |
| 318 | </p> |
| 319 | </div> |
| 320 | </div> |
| 321 | <h2>SYNOPSIS</h2> |
| 322 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 323 | <div class="para"><p>$GIT_DIR/hooks/*</p></div> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 324 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 325 | <h2 id="_description">DESCRIPTION</h2> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 326 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 327 | <div class="para"><p>Hooks are little scripts you can place in <tt>$GIT_DIR/hooks</tt> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 328 | directory to trigger action at certain points. When |
Junio C Hamano | 6efe302 | 2009-01-13 16:47:56 | [diff] [blame] | 329 | <em>git-init</em> is run, a handful of example hooks are copied into the |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 330 | <tt>hooks</tt> directory of the new repository, but by default they are |
Junio C Hamano | 6aff399 | 2008-06-25 08:07:44 | [diff] [blame] | 331 | all disabled. To enable a hook, rename it by removing its <tt>.sample</tt> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 332 | suffix.</p></div> |
Junio C Hamano | 8a48fa2 | 2008-12-18 08:44:30 | [diff] [blame] | 333 | <div class="admonitionblock"> |
| 334 | <table><tr> |
| 335 | <td class="icon"> |
| 336 | <div class="title">Note</div> |
| 337 | </td> |
| 338 | <td class="content">It is also a requirement for a given hook to be executable. |
| 339 | However - in a freshly initialized repository - the <tt>.sample</tt> files are |
| 340 | executable by default.</td> |
| 341 | </tr></table> |
| 342 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 343 | <div class="para"><p>This document describes the currently defined hooks.</p></div> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 344 | </div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 345 | <h2 id="_hooks">HOOKS</h2> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 346 | <div class="sectionbody"> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 347 | <h3 id="_applypatch_msg">applypatch-msg</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 348 | <div class="para"><p>This hook is invoked by <em>git-am</em> script. It takes a single |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 349 | parameter, the name of the file that holds the proposed commit |
| 350 | log message. Exiting with non-zero status causes |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 351 | <em>git-am</em> to abort before applying the patch.</p></div> |
| 352 | <div class="para"><p>The hook is allowed to edit the message file in place, and can |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 353 | be used to normalize the message into some project standard |
| 354 | format (if the project has one). It can also be used to refuse |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 355 | the commit after inspecting the message file.</p></div> |
| 356 | <div class="para"><p>The default <em>applypatch-msg</em> hook, when enabled, runs the |
| 357 | <em>commit-msg</em> hook, if the latter is enabled.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 358 | <h3 id="_pre_applypatch">pre-applypatch</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 359 | <div class="para"><p>This hook is invoked by <em>git-am</em>. It takes no parameter, and is |
| 360 | invoked after the patch is applied, but before a commit is made.</p></div> |
| 361 | <div class="para"><p>If it exits with non-zero status, then the working tree will not be |
| 362 | committed after applying the patch.</p></div> |
| 363 | <div class="para"><p>It can be used to inspect the current working tree and refuse to |
| 364 | make a commit if it does not pass certain test.</p></div> |
| 365 | <div class="para"><p>The default <em>pre-applypatch</em> hook, when enabled, runs the |
| 366 | <em>pre-commit</em> hook, if the latter is enabled.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 367 | <h3 id="_post_applypatch">post-applypatch</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 368 | <div class="para"><p>This hook is invoked by <em>git-am</em>. It takes no parameter, |
| 369 | and is invoked after the patch is applied and a commit is made.</p></div> |
| 370 | <div class="para"><p>This hook is meant primarily for notification, and cannot affect |
| 371 | the outcome of <em>git-am</em>.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 372 | <h3 id="_pre_commit">pre-commit</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 373 | <div class="para"><p>This hook is invoked by <em>git-commit</em>, and can be bypassed |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 374 | with <tt>--no-verify</tt> option. It takes no parameter, and is |
| 375 | invoked before obtaining the proposed commit log message and |
| 376 | making a commit. Exiting with non-zero status from this script |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 377 | causes the <em>git-commit</em> to abort.</p></div> |
| 378 | <div class="para"><p>The default <em>pre-commit</em> hook, when enabled, catches introduction |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 379 | of lines with trailing whitespaces and aborts the commit when |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 380 | such a line is found.</p></div> |
| 381 | <div class="para"><p>All the <em>git-commit</em> hooks are invoked with the environment |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 382 | variable <tt>GIT_EDITOR=:</tt> if the command will not bring up an editor |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 383 | to modify the commit message.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 384 | <h3 id="_prepare_commit_msg">prepare-commit-msg</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 385 | <div class="para"><p>This hook is invoked by <em>git-commit</em> right after preparing the |
| 386 | default log message, and before the editor is started.</p></div> |
| 387 | <div class="para"><p>It takes one to three parameters. The first is the name of the file |
Junio C Hamano | bd53dbf | 2009-01-18 18:26:37 | [diff] [blame] | 388 | that contains the commit log message. The second is the source of the commit |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 389 | message, and can be: <tt>message</tt> (if a <tt>-m</tt> or <tt>-F</tt> option was |
| 390 | given); <tt>template</tt> (if a <tt>-t</tt> option was given or the |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 391 | configuration option <tt>commit.template</tt> is set); <tt>merge</tt> (if the |
| 392 | commit is a merge or a <tt>.git/MERGE_MSG</tt> file exists); <tt>squash</tt> |
| 393 | (if a <tt>.git/SQUASH_MSG</tt> file exists); or <tt>commit</tt>, followed by |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 394 | a commit SHA1 (if a <tt>-c</tt>, <tt>-C</tt> or <tt>--amend</tt> option was given).</p></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 395 | <div class="para"><p>If the exit status is non-zero, <em>git-commit</em> will abort.</p></div> |
| 396 | <div class="para"><p>The purpose of the hook is to edit the message file in place, and |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 397 | it is not suppressed by the <tt>--no-verify</tt> option. A non-zero exit |
| 398 | means a failure of the hook and aborts the commit. It should not |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 399 | be used as replacement for pre-commit hook.</p></div> |
| 400 | <div class="para"><p>The sample <tt>prepare-commit-msg</tt> hook that comes with git comments |
| 401 | out the <tt>Conflicts:</tt> part of a merge's commit message.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 402 | <h3 id="_commit_msg">commit-msg</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 403 | <div class="para"><p>This hook is invoked by <em>git-commit</em>, and can be bypassed |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 404 | with <tt>--no-verify</tt> option. It takes a single parameter, the |
| 405 | name of the file that holds the proposed commit log message. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 406 | Exiting with non-zero status causes the <em>git-commit</em> to |
| 407 | abort.</p></div> |
| 408 | <div class="para"><p>The hook is allowed to edit the message file in place, and can |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 409 | be used to normalize the message into some project standard |
| 410 | format (if the project has one). It can also be used to refuse |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 411 | the commit after inspecting the message file.</p></div> |
| 412 | <div class="para"><p>The default <em>commit-msg</em> hook, when enabled, detects duplicate |
| 413 | "Signed-off-by" lines, and aborts the commit if one is found.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 414 | <h3 id="_post_commit">post-commit</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 415 | <div class="para"><p>This hook is invoked by <em>git-commit</em>. It takes no |
| 416 | parameter, and is invoked after a commit is made.</p></div> |
| 417 | <div class="para"><p>This hook is meant primarily for notification, and cannot affect |
| 418 | the outcome of <em>git-commit</em>.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 419 | <h3 id="_pre_rebase">pre-rebase</h3><div style="clear:left"></div> |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 420 | <div class="para"><p>This hook is called by <em>git-rebase</em> and can be used to prevent a branch |
| 421 | from getting rebased.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 422 | <h3 id="_post_checkout">post-checkout</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 423 | <div class="para"><p>This hook is invoked when a <em>git-checkout</em> is run after having updated the |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 424 | worktree. The hook is given three parameters: the ref of the previous HEAD, |
| 425 | the ref of the new HEAD (which may or may not have changed), and a flag |
| 426 | indicating whether the checkout was a branch checkout (changing branches, |
| 427 | flag=1) or a file checkout (retrieving a file from the index, flag=0). |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 428 | This hook cannot affect the outcome of <em>git-checkout</em>.</p></div> |
Junio C Hamano | 36a5672 | 2009-03-28 08:55:34 | [diff] [blame] | 429 | <div class="para"><p>It is also run after <em>git-clone</em>, unless the --no-checkout (-n) option is |
| 430 | used. The first parameter given to the hook is the null-ref, the second the |
| 431 | ref of the new HEAD and the flag is always 1.</p></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 432 | <div class="para"><p>This hook can be used to perform repository validity checks, auto-display |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 433 | differences from the previous HEAD if different, or set working dir metadata |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 434 | properties.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 435 | <h3 id="_post_merge">post-merge</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 436 | <div class="para"><p>This hook is invoked by <em>git-merge</em>, which happens when a <em>git-pull</em> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 437 | is done on a local repository. The hook takes a single parameter, a status |
| 438 | flag specifying whether or not the merge being done was a squash merge. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 439 | This hook cannot affect the outcome of <em>git-merge</em> and is not executed, |
| 440 | if the merge failed due to conflicts.</p></div> |
| 441 | <div class="para"><p>This hook can be used in conjunction with a corresponding pre-commit hook to |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 442 | save and restore any form of metadata associated with the working tree |
| 443 | (eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 444 | for an example of how to do this.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 445 | <h3 id="pre-receive">pre-receive</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 446 | <div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository, |
| 447 | which happens when a <em>git-push</em> is done on a local repository. |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 448 | Just before starting to update refs on the remote repository, the |
| 449 | pre-receive hook is invoked. Its exit status determines the success |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 450 | or failure of the update.</p></div> |
| 451 | <div class="para"><p>This hook executes once for the receive operation. It takes no |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 452 | arguments, but for each ref to be updated it receives on standard |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 453 | input a line of the format:</p></div> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 454 | <div class="literalblock"> |
| 455 | <div class="content"> |
| 456 | <pre><tt><old-value> SP <new-value> SP <ref-name> LF</tt></pre> |
| 457 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 458 | <div class="para"><p>where <tt><old-value></tt> is the old object name stored in the ref, |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 459 | <tt><new-value></tt> is the new object name to be stored in the ref and |
| 460 | <tt><ref-name></tt> is the full name of the ref. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 461 | When creating a new ref, <tt><old-value></tt> is 40 <tt>0</tt>.</p></div> |
| 462 | <div class="para"><p>If the hook exits with non-zero status, none of the refs will be |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 463 | updated. If the hook exits with zero, updating of individual refs can |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 464 | still be prevented by the <a href="#update"><em>update</em></a> hook.</p></div> |
| 465 | <div class="para"><p>Both standard output and standard error output are forwarded to |
| 466 | <em>git-send-pack</em> on the other end, so you can simply <tt>echo</tt> messages |
| 467 | for the user.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 468 | <h3 id="update">update</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 469 | <div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository, |
| 470 | which happens when a <em>git-push</em> is done on a local repository. |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 471 | Just before updating the ref on the remote repository, the update hook |
| 472 | is invoked. Its exit status determines the success or failure of |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 473 | the ref update.</p></div> |
| 474 | <div class="para"><p>The hook executes once for each ref to be updated, and takes |
| 475 | three parameters:</p></div> |
| 476 | <div class="ilist"><ul> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 477 | <li> |
| 478 | <p> |
| 479 | the name of the ref being updated, |
| 480 | </p> |
| 481 | </li> |
| 482 | <li> |
| 483 | <p> |
| 484 | the old object name stored in the ref, |
| 485 | </p> |
| 486 | </li> |
| 487 | <li> |
| 488 | <p> |
| 489 | and the new objectname to be stored in the ref. |
| 490 | </p> |
| 491 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 492 | </ul></div> |
| 493 | <div class="para"><p>A zero exit from the update hook allows the ref to be updated. |
| 494 | Exiting with a non-zero status prevents <em>git-receive-pack</em> |
| 495 | from updating that ref.</p></div> |
| 496 | <div class="para"><p>This hook can be used to prevent <em>forced</em> update on certain refs by |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 497 | making sure that the object name is a commit object that is a |
| 498 | descendant of the commit object named by the old object name. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 499 | That is, to enforce a "fast forward only" policy.</p></div> |
| 500 | <div class="para"><p>It could also be used to log the old..new status. However, it |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 501 | does not know the entire set of branches, so it would end up |
| 502 | firing one e-mail per ref when used naively, though. The |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 503 | <a href="#post-receive"><em>post-receive</em></a> hook is more suited to that.</p></div> |
| 504 | <div class="para"><p>Another use suggested on the mailing list is to use this hook to |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 505 | implement access control which is finer grained than the one |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 506 | based on filesystem group.</p></div> |
| 507 | <div class="para"><p>Both standard output and standard error output are forwarded to |
| 508 | <em>git-send-pack</em> on the other end, so you can simply <tt>echo</tt> messages |
| 509 | for the user.</p></div> |
| 510 | <div class="para"><p>The default <em>update</em> hook, when enabled--and with |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 511 | <tt>hooks.allowunannotated</tt> config option turned on--prevents |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 512 | unannotated tags to be pushed.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 513 | <h3 id="post-receive">post-receive</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 514 | <div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository, |
| 515 | which happens when a <em>git-push</em> is done on a local repository. |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 516 | It executes on the remote repository once after all the refs have |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 517 | been updated.</p></div> |
| 518 | <div class="para"><p>This hook executes once for the receive operation. It takes no |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 519 | arguments, but gets the same information as the |
| 520 | <a href="#pre-receive"><em>pre-receive</em></a> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 521 | hook does on its standard input.</p></div> |
| 522 | <div class="para"><p>This hook does not affect the outcome of <em>git-receive-pack</em>, as it |
| 523 | is called after the real work is done.</p></div> |
| 524 | <div class="para"><p>This supersedes the <a href="#post-update"><em>post-update</em></a> hook in that it gets |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 525 | both old and new values of all the refs in addition to their |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 526 | names.</p></div> |
| 527 | <div class="para"><p>Both standard output and standard error output are forwarded to |
| 528 | <em>git-send-pack</em> on the other end, so you can simply <tt>echo</tt> messages |
| 529 | for the user.</p></div> |
| 530 | <div class="para"><p>The default <em>post-receive</em> hook is empty, but there is |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 531 | a sample script <tt>post-receive-email</tt> provided in the <tt>contrib/hooks</tt> |
| 532 | directory in git distribution, which implements sending commit |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 533 | emails.</p></div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 534 | <h3 id="post-update">post-update</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 535 | <div class="para"><p>This hook is invoked by <em>git-receive-pack</em> on the remote repository, |
| 536 | which happens when a <em>git-push</em> is done on a local repository. |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 537 | It executes on the remote repository once after all the refs have |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 538 | been updated.</p></div> |
| 539 | <div class="para"><p>It takes a variable number of parameters, each of which is the |
| 540 | name of ref that was actually updated.</p></div> |
| 541 | <div class="para"><p>This hook is meant primarily for notification, and cannot affect |
| 542 | the outcome of <em>git-receive-pack</em>.</p></div> |
| 543 | <div class="para"><p>The <em>post-update</em> hook can tell what are the heads that were pushed, |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 544 | but it does not know what their original and updated values are, |
| 545 | so it is a poor place to do log old..new. The |
| 546 | <a href="#post-receive"><em>post-receive</em></a> hook does get both original and |
| 547 | updated values of the refs. You might consider it instead if you need |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 548 | them.</p></div> |
| 549 | <div class="para"><p>When enabled, the default <em>post-update</em> hook runs |
| 550 | <em>git-update-server-info</em> to keep the information used by dumb |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 551 | transports (e.g., HTTP) up-to-date. If you are publishing |
| 552 | a git repository that is accessible via HTTP, you should |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 553 | probably enable this hook.</p></div> |
| 554 | <div class="para"><p>Both standard output and standard error output are forwarded to |
| 555 | <em>git-send-pack</em> on the other end, so you can simply <tt>echo</tt> messages |
| 556 | for the user.</p></div> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 557 | </div> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 558 | <h2 id="_post_upload_pack">post-upload-pack</h2> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 559 | <div class="sectionbody"> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 560 | <div class="para"><p>After upload-pack successfully finishes its operation, this hook is called |
| 561 | for logging purposes.</p></div> |
| 562 | <div class="para"><p>The hook is passed various pieces of information, one per line, from its |
| 563 | standard input. Currently the following items can be fed to the hook, but |
| 564 | more types of information may be added in the future:</p></div> |
| 565 | <div class="vlist"><dl> |
| 566 | <dt> |
| 567 | want SHA-1 |
| 568 | </dt> |
| 569 | <dd> |
| 570 | <p> |
| 571 | 40-byte hexadecimal object name the client asked to include in the |
| 572 | resulting pack. Can occur one or more times in the input. |
| 573 | </p> |
| 574 | </dd> |
| 575 | <dt> |
| 576 | have SHA-1 |
| 577 | </dt> |
| 578 | <dd> |
| 579 | <p> |
| 580 | 40-byte hexadecimal object name the client asked to exclude from |
| 581 | the resulting pack, claiming to have them already. Can occur zero |
| 582 | or more times in the input. |
| 583 | </p> |
| 584 | </dd> |
| 585 | <dt> |
| 586 | time float |
| 587 | </dt> |
| 588 | <dd> |
| 589 | <p> |
| 590 | Number of seconds spent for creating the packfile. |
| 591 | </p> |
| 592 | </dd> |
| 593 | <dt> |
| 594 | size decimal |
| 595 | </dt> |
| 596 | <dd> |
| 597 | <p> |
| 598 | Size of the resulting packfile in bytes. |
| 599 | </p> |
| 600 | </dd> |
| 601 | </dl></div> |
| 602 | <div class="para"><p>kind string: |
| 603 | Either "clone" (when the client did not give us any "have", and asked |
| 604 | for all our refs with "want"), or "fetch" (otherwise).</p></div> |
| 605 | <h3 id="_pre_auto_gc">pre-auto-gc</h3><div style="clear:left"></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 606 | <div class="para"><p>This hook is invoked by <em>git-gc --auto</em>. It takes no parameter, and |
| 607 | exiting with non-zero status from this script causes the <em>git-gc --auto</em> |
| 608 | to abort.</p></div> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 609 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 610 | <h2 id="_git">GIT</h2> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 611 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 612 | <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div> |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 613 | </div> |
| 614 | <div id="footer"> |
| 615 | <div id="footer-text"> |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame^] | 616 | Last updated 2009-09-08 00:55:01 UTC |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 617 | </div> |
| 618 | </div> |
| 619 | </body> |
| 620 | </html> |