Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [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 | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 7.0.2" /> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [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 | |
| 19 | a { color: blue; } |
| 20 | a:visited { color: fuchsia; } |
| 21 | |
| 22 | em { |
| 23 | font-style: italic; |
| 24 | } |
| 25 | |
| 26 | strong { |
| 27 | font-weight: bold; |
| 28 | } |
| 29 | |
| 30 | tt { |
| 31 | color: navy; |
| 32 | } |
| 33 | |
| 34 | h1, h2, h3, h4, h5, h6 { |
| 35 | color: #527bbd; |
| 36 | font-family: sans-serif; |
| 37 | margin-top: 1.2em; |
| 38 | margin-bottom: 0.5em; |
| 39 | line-height: 1.3; |
| 40 | } |
| 41 | |
| 42 | h1 { |
| 43 | border-bottom: 2px solid silver; |
| 44 | } |
| 45 | h2 { |
| 46 | border-bottom: 2px solid silver; |
| 47 | padding-top: 0.5em; |
| 48 | } |
| 49 | |
| 50 | div.sectionbody { |
| 51 | font-family: serif; |
| 52 | margin-left: 0; |
| 53 | } |
| 54 | |
| 55 | hr { |
| 56 | border: 1px solid silver; |
| 57 | } |
| 58 | |
| 59 | p { |
| 60 | margin-top: 0.5em; |
| 61 | margin-bottom: 0.5em; |
| 62 | } |
| 63 | |
| 64 | pre { |
| 65 | padding: 0; |
| 66 | margin: 0; |
| 67 | } |
| 68 | |
| 69 | span#author { |
| 70 | color: #527bbd; |
| 71 | font-family: sans-serif; |
| 72 | font-weight: bold; |
| 73 | font-size: 1.2em; |
| 74 | } |
| 75 | span#email { |
| 76 | } |
| 77 | span#revision { |
| 78 | font-family: sans-serif; |
| 79 | } |
| 80 | |
| 81 | div#footer { |
| 82 | font-family: sans-serif; |
| 83 | font-size: small; |
| 84 | border-top: 2px solid silver; |
| 85 | padding-top: 0.5em; |
| 86 | margin-top: 4.0em; |
| 87 | } |
| 88 | div#footer-text { |
| 89 | float: left; |
| 90 | padding-bottom: 0.5em; |
| 91 | } |
| 92 | div#footer-badges { |
| 93 | float: right; |
| 94 | padding-bottom: 0.5em; |
| 95 | } |
| 96 | |
| 97 | div#preamble, |
| 98 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 99 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 100 | div.admonitionblock { |
| 101 | margin-right: 10%; |
| 102 | margin-top: 1.5em; |
| 103 | margin-bottom: 1.5em; |
| 104 | } |
| 105 | div.admonitionblock { |
| 106 | margin-top: 2.5em; |
| 107 | margin-bottom: 2.5em; |
| 108 | } |
| 109 | |
| 110 | div.content { /* Block element content. */ |
| 111 | padding: 0; |
| 112 | } |
| 113 | |
| 114 | /* Block element titles. */ |
| 115 | div.title, caption.title { |
| 116 | font-family: sans-serif; |
| 117 | font-weight: bold; |
| 118 | text-align: left; |
| 119 | margin-top: 1.0em; |
| 120 | margin-bottom: 0.5em; |
| 121 | } |
| 122 | div.title + * { |
| 123 | margin-top: 0; |
| 124 | } |
| 125 | |
| 126 | td div.title:first-child { |
| 127 | margin-top: 0.0em; |
| 128 | } |
| 129 | div.content div.title:first-child { |
| 130 | margin-top: 0.0em; |
| 131 | } |
| 132 | div.content + div.title { |
| 133 | margin-top: 0.0em; |
| 134 | } |
| 135 | |
| 136 | div.sidebarblock > div.content { |
| 137 | background: #ffffee; |
| 138 | border: 1px solid silver; |
| 139 | padding: 0.5em; |
| 140 | } |
| 141 | |
| 142 | div.listingblock > div.content { |
| 143 | border: 1px solid silver; |
| 144 | background: #f4f4f4; |
| 145 | padding: 0.5em; |
| 146 | } |
| 147 | |
| 148 | div.quoteblock > div.content { |
| 149 | padding-left: 2.0em; |
| 150 | } |
| 151 | div.quoteblock .attribution { |
| 152 | text-align: right; |
| 153 | } |
| 154 | |
| 155 | div.admonitionblock .icon { |
| 156 | vertical-align: top; |
| 157 | font-size: 1.1em; |
| 158 | font-weight: bold; |
| 159 | text-decoration: underline; |
| 160 | color: #527bbd; |
| 161 | padding-right: 0.5em; |
| 162 | } |
| 163 | div.admonitionblock td.content { |
| 164 | padding-left: 0.5em; |
| 165 | border-left: 2px solid silver; |
| 166 | } |
| 167 | |
| 168 | div.exampleblock > div.content { |
| 169 | border-left: 2px solid silver; |
| 170 | padding: 0.5em; |
| 171 | } |
| 172 | |
| 173 | div.verseblock div.content { |
| 174 | white-space: pre; |
| 175 | } |
| 176 | |
| 177 | div.imageblock div.content { padding-left: 0; } |
| 178 | div.imageblock img { border: 1px solid silver; } |
| 179 | span.image img { border-style: none; } |
| 180 | |
| 181 | dl { |
| 182 | margin-top: 0.8em; |
| 183 | margin-bottom: 0.8em; |
| 184 | } |
| 185 | dt { |
| 186 | margin-top: 0.5em; |
| 187 | margin-bottom: 0; |
| 188 | font-style: italic; |
| 189 | } |
| 190 | dd > *:first-child { |
| 191 | margin-top: 0; |
| 192 | } |
| 193 | |
| 194 | ul, ol { |
| 195 | list-style-position: outside; |
| 196 | } |
| 197 | ol.olist2 { |
| 198 | list-style-type: lower-alpha; |
| 199 | } |
| 200 | |
| 201 | div.tableblock > table { |
| 202 | border-color: #527bbd; |
| 203 | border-width: 3px; |
| 204 | } |
| 205 | thead { |
| 206 | font-family: sans-serif; |
| 207 | font-weight: bold; |
| 208 | } |
| 209 | tfoot { |
| 210 | font-weight: bold; |
| 211 | } |
| 212 | |
| 213 | div.hlist { |
| 214 | margin-top: 0.8em; |
| 215 | margin-bottom: 0.8em; |
| 216 | } |
| 217 | td.hlist1 { |
| 218 | vertical-align: top; |
| 219 | font-style: italic; |
| 220 | padding-right: 0.8em; |
| 221 | } |
| 222 | td.hlist2 { |
| 223 | vertical-align: top; |
| 224 | } |
| 225 | |
| 226 | @media print { |
| 227 | div#footer-badges { display: none; } |
| 228 | } |
| 229 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 230 | |
| 231 | div.sidebar-content { |
| 232 | background: #ffffee; |
| 233 | border: 1px solid silver; |
| 234 | padding: 0.5em; |
| 235 | } |
| 236 | div.sidebar-title, div.image-title { |
| 237 | font-family: sans-serif; |
| 238 | font-weight: bold; |
| 239 | margin-top: 0.0em; |
| 240 | margin-bottom: 0.5em; |
| 241 | } |
| 242 | |
| 243 | div.listingblock div.content { |
| 244 | border: 1px solid silver; |
| 245 | background: #f4f4f4; |
| 246 | padding: 0.5em; |
| 247 | } |
| 248 | |
| 249 | div.quoteblock-content { |
| 250 | padding-left: 2.0em; |
| 251 | } |
| 252 | |
| 253 | div.exampleblock-content { |
| 254 | border-left: 2px solid silver; |
| 255 | padding-left: 0.5em; |
| 256 | } |
| 257 | </style> |
| 258 | <title>Hooks used by git</title> |
| 259 | </head> |
| 260 | <body> |
| 261 | <div id="header"> |
| 262 | <h1>Hooks used by git</h1> |
| 263 | </div> |
| 264 | <div id="preamble"> |
| 265 | <div class="sectionbody"> |
| 266 | <p>Hooks are little scripts you can place in <tt>$GIT_DIR/hooks</tt> |
| 267 | directory to trigger action at certain points. When |
Junio C Hamano | 24351a8 | 2007-01-13 08:09:17 | [diff] [blame] | 268 | <tt>git-init</tt> is run, a handful example hooks are copied in the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 269 | <tt>hooks</tt> directory of the new repository, but by default they are |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 270 | all disabled. To enable a hook, make it executable with <tt>chmod +x</tt>.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 271 | <p>This document describes the currently defined hooks.</p> |
| 272 | </div> |
| 273 | </div> |
| 274 | <h2>applypatch-msg</h2> |
| 275 | <div class="sectionbody"> |
Junio C Hamano | 38b693c | 2007-06-03 08:40:14 | [diff] [blame] | 276 | <p>This hook is invoked by <tt>git-am</tt> script. It takes a single |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 277 | parameter, the name of the file that holds the proposed commit |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 278 | log message. Exiting with non-zero status causes |
Junio C Hamano | 38b693c | 2007-06-03 08:40:14 | [diff] [blame] | 279 | <tt>git-am</tt> to abort before applying the patch.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 280 | <p>The hook is allowed to edit the message file in place, and can |
| 281 | be used to normalize the message into some project standard |
| 282 | format (if the project has one). It can also be used to refuse |
| 283 | the commit after inspecting the message file.</p> |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 284 | <p>The default <em>applypatch-msg</em> hook, when enabled, runs the |
| 285 | <em>commit-msg</em> hook, if the latter is enabled.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 286 | </div> |
| 287 | <h2>pre-applypatch</h2> |
| 288 | <div class="sectionbody"> |
Junio C Hamano | 38b693c | 2007-06-03 08:40:14 | [diff] [blame] | 289 | <p>This hook is invoked by <tt>git-am</tt>. It takes no parameter, |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 290 | and is invoked after the patch is applied, but before a commit |
| 291 | is made. Exiting with non-zero status causes the working tree |
| 292 | after application of the patch not committed.</p> |
| 293 | <p>It can be used to inspect the current working tree and refuse to |
| 294 | make a commit if it does not pass certain test.</p> |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 295 | <p>The default <em>pre-applypatch</em> hook, when enabled, runs the |
| 296 | <em>pre-commit</em> hook, if the latter is enabled.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 297 | </div> |
| 298 | <h2>post-applypatch</h2> |
| 299 | <div class="sectionbody"> |
Junio C Hamano | 38b693c | 2007-06-03 08:40:14 | [diff] [blame] | 300 | <p>This hook is invoked by <tt>git-am</tt>. It takes no parameter, |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 301 | and is invoked after the patch is applied and a commit is made.</p> |
| 302 | <p>This hook is meant primarily for notification, and cannot affect |
Junio C Hamano | 38b693c | 2007-06-03 08:40:14 | [diff] [blame] | 303 | the outcome of <tt>git-am</tt>.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 304 | </div> |
| 305 | <h2>pre-commit</h2> |
| 306 | <div class="sectionbody"> |
| 307 | <p>This hook is invoked by <tt>git-commit</tt>, and can be bypassed |
| 308 | with <tt>--no-verify</tt> option. It takes no parameter, and is |
| 309 | invoked before obtaining the proposed commit log message and |
| 310 | making a commit. Exiting with non-zero status from this script |
| 311 | causes the <tt>git-commit</tt> to abort.</p> |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 312 | <p>The default <em>pre-commit</em> hook, when enabled, catches introduction |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 313 | of lines with trailing whitespaces and aborts the commit when |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 314 | such a line is found.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 315 | </div> |
| 316 | <h2>commit-msg</h2> |
| 317 | <div class="sectionbody"> |
| 318 | <p>This hook is invoked by <tt>git-commit</tt>, and can be bypassed |
| 319 | with <tt>--no-verify</tt> option. It takes a single parameter, the |
| 320 | name of the file that holds the proposed commit log message. |
| 321 | Exiting with non-zero status causes the <tt>git-commit</tt> to |
| 322 | abort.</p> |
| 323 | <p>The hook is allowed to edit the message file in place, and can |
| 324 | be used to normalize the message into some project standard |
| 325 | format (if the project has one). It can also be used to refuse |
| 326 | the commit after inspecting the message file.</p> |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 327 | <p>The default <em>commit-msg</em> hook, when enabled, detects duplicate |
| 328 | "Signed-off-by" lines, and aborts the commit if one is found.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 329 | </div> |
| 330 | <h2>post-commit</h2> |
| 331 | <div class="sectionbody"> |
| 332 | <p>This hook is invoked by <tt>git-commit</tt>. It takes no |
| 333 | parameter, and is invoked after a commit is made.</p> |
| 334 | <p>This hook is meant primarily for notification, and cannot affect |
| 335 | the outcome of <tt>git-commit</tt>.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 336 | </div> |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 337 | <h2>post-checkout</h2> |
| 338 | <div class="sectionbody"> |
| 339 | <p>This hook is invoked when a <tt>git-checkout</tt> is run after having updated the |
| 340 | worktree. The hook is given three parameters: the ref of the previous HEAD, |
| 341 | the ref of the new HEAD (which may or may not have changed), and a flag |
| 342 | indicating whether the checkout was a branch checkout (changing branches, |
| 343 | flag=1) or a file checkout (retrieving a file from the index, flag=0). |
| 344 | This hook cannot affect the outcome of <tt>git-checkout</tt>.</p> |
| 345 | <p>This hook can be used to perform repository validity checks, auto-display |
| 346 | differences from the previous HEAD if different, or set working dir metadata |
| 347 | properties.</p> |
| 348 | </div> |
Junio C Hamano | 01d8f83 | 2007-09-24 07:37:30 | [diff] [blame] | 349 | <h2>post-merge</h2> |
| 350 | <div class="sectionbody"> |
| 351 | <p>This hook is invoked by <tt>git-merge</tt>, which happens when a <tt>git pull</tt> |
| 352 | is done on a local repository. The hook takes a single parameter, a status |
| 353 | flag specifying whether or not the merge being done was a squash merge. |
| 354 | This hook cannot affect the outcome of <tt>git-merge</tt>.</p> |
| 355 | <p>This hook can be used in conjunction with a corresponding pre-commit hook to |
| 356 | save and restore any form of metadata associated with the working tree |
| 357 | (eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl |
| 358 | for an example of how to do this.</p> |
| 359 | </div> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 360 | <h2><a id="pre-receive"></a>pre-receive</h2> |
| 361 | <div class="sectionbody"> |
| 362 | <p>This hook is invoked by <tt>git-receive-pack</tt> on the remote repository, |
| 363 | which happens when a <tt>git push</tt> is done on a local repository. |
| 364 | Just before starting to update refs on the remote repository, the |
| 365 | pre-receive hook is invoked. Its exit status determines the success |
| 366 | or failure of the update.</p> |
| 367 | <p>This hook executes once for the receive operation. It takes no |
| 368 | arguments, but for each ref to be updated it receives on standard |
| 369 | input a line of the format:</p> |
| 370 | <div class="literalblock"> |
| 371 | <div class="content"> |
| 372 | <pre><tt><old-value> SP <new-value> SP <ref-name> LF</tt></pre> |
| 373 | </div></div> |
| 374 | <p>where <tt><old-value></tt> is the old object name stored in the ref, |
| 375 | <tt><new-value></tt> is the new object name to be stored in the ref and |
| 376 | <tt><ref-name></tt> is the full name of the ref. |
| 377 | When creating a new ref, <tt><old-value></tt> is 40 <tt>0</tt>.</p> |
| 378 | <p>If the hook exits with non-zero status, none of the refs will be |
| 379 | updated. If the hook exits with zero, updating of individual refs can |
| 380 | still be prevented by the <a href="#update"><em>update</em></a> hook.</p> |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 381 | <p>Both standard output and standard error output are forwarded to |
| 382 | <tt>git-send-pack</tt> on the other end, so you can simply <tt>echo</tt> messages |
| 383 | for the user.</p> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 384 | </div> |
| 385 | <h2><a id="update"></a>update</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 386 | <div class="sectionbody"> |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 387 | <p>This hook is invoked by <tt>git-receive-pack</tt> on the remote repository, |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 388 | which happens when a <tt>git push</tt> is done on a local repository. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 389 | Just before updating the ref on the remote repository, the update hook |
Junio C Hamano | 33db437 | 2006-06-07 19:51:45 | [diff] [blame] | 390 | is invoked. Its exit status determines the success or failure of |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 391 | the ref update.</p> |
| 392 | <p>The hook executes once for each ref to be updated, and takes |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 393 | three parameters:</p> |
| 394 | <ul> |
| 395 | <li> |
| 396 | <p> |
| 397 | the name of the ref being updated, |
| 398 | </p> |
| 399 | </li> |
| 400 | <li> |
| 401 | <p> |
| 402 | the old object name stored in the ref, |
| 403 | </p> |
| 404 | </li> |
| 405 | <li> |
| 406 | <p> |
| 407 | and the new objectname to be stored in the ref. |
| 408 | </p> |
| 409 | </li> |
| 410 | </ul> |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 411 | <p>A zero exit from the update hook allows the ref to be updated. |
| 412 | Exiting with a non-zero status prevents <tt>git-receive-pack</tt> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 413 | from updating that ref.</p> |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 414 | <p>This hook can be used to prevent <em>forced</em> update on certain refs by |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 415 | making sure that the object name is a commit object that is a |
| 416 | descendant of the commit object named by the old object name. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 417 | That is, to enforce a "fast forward only" policy.</p> |
| 418 | <p>It could also be used to log the old..new status. However, it |
| 419 | does not know the entire set of branches, so it would end up |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 420 | firing one e-mail per ref when used naively, though. The |
| 421 | <a href="#post-receive"><em>post-receive</em></a> hook is more suited to that.</p> |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 422 | <p>Another use suggested on the mailing list is to use this hook to |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 423 | implement access control which is finer grained than the one |
| 424 | based on filesystem group.</p> |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 425 | <p>Both standard output and standard error output are forwarded to |
| 426 | <tt>git-send-pack</tt> on the other end, so you can simply <tt>echo</tt> messages |
| 427 | for the user.</p> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 428 | <p>The default <em>update</em> hook, when enabled—and with |
| 429 | <tt>hooks.allowunannotated</tt> config option turned on—prevents |
| 430 | unannotated tags to be pushed.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 431 | </div> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 432 | <h2><a id="post-receive"></a>post-receive</h2> |
| 433 | <div class="sectionbody"> |
| 434 | <p>This hook is invoked by <tt>git-receive-pack</tt> on the remote repository, |
| 435 | which happens when a <tt>git push</tt> is done on a local repository. |
| 436 | It executes on the remote repository once after all the refs have |
| 437 | been updated.</p> |
| 438 | <p>This hook executes once for the receive operation. It takes no |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 439 | arguments, but gets the same information as the |
| 440 | <a href="#pre-receive"><em>pre-receive</em></a> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 441 | hook does on its standard input.</p> |
| 442 | <p>This hook does not affect the outcome of <tt>git-receive-pack</tt>, as it |
| 443 | is called after the real work is done.</p> |
Junio C Hamano | a638742 | 2007-08-25 03:54:27 | [diff] [blame] | 444 | <p>This supersedes the <a href="#post-update"><em>post-update</em></a> hook in that it gets |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 445 | both old and new values of all the refs in addition to their |
| 446 | names.</p> |
| 447 | <p>Both standard output and standard error output are forwarded to |
| 448 | <tt>git-send-pack</tt> on the other end, so you can simply <tt>echo</tt> messages |
| 449 | for the user.</p> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 450 | <p>The default <em>post-receive</em> hook is empty, but there is |
| 451 | a sample script <tt>post-receive-email</tt> provided in the <tt>contrib/hooks</tt> |
| 452 | directory in git distribution, which implements sending commit |
| 453 | emails.</p> |
| 454 | </div> |
| 455 | <h2><a id="post-update"></a>post-update</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 456 | <div class="sectionbody"> |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 457 | <p>This hook is invoked by <tt>git-receive-pack</tt> on the remote repository, |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 458 | which happens when a <tt>git push</tt> is done on a local repository. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 459 | It executes on the remote repository once after all the refs have |
| 460 | been updated.</p> |
| 461 | <p>It takes a variable number of parameters, each of which is the |
| 462 | name of ref that was actually updated.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 463 | <p>This hook is meant primarily for notification, and cannot affect |
| 464 | the outcome of <tt>git-receive-pack</tt>.</p> |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 465 | <p>The <em>post-update</em> hook can tell what are the heads that were pushed, |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 466 | but it does not know what their original and updated values are, |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 467 | so it is a poor place to do log old..new. The |
| 468 | <a href="#post-receive"><em>post-receive</em></a> hook does get both original and |
| 469 | updated values of the refs. You might consider it instead if you need |
| 470 | them.</p> |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 471 | <p>When enabled, the default <em>post-update</em> hook runs |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 472 | <tt>git-update-server-info</tt> to keep the information used by dumb |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 473 | transports (e.g., HTTP) up-to-date. If you are publishing |
| 474 | a git repository that is accessible via HTTP, you should |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 475 | probably enable this hook.</p> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 476 | <p>Both standard output and standard error output are forwarded to |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 477 | <tt>git-send-pack</tt> on the other end, so you can simply <tt>echo</tt> messages |
| 478 | for the user.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 479 | </div> |
| 480 | <div id="footer"> |
| 481 | <div id="footer-text"> |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 482 | Last updated 03-Oct-2007 12:03:51 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 483 | </div> |
| 484 | </div> |
| 485 | </body> |
| 486 | </html> |