Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 1 | githooks(5) |
| 2 | =========== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | githooks - Hooks used by git |
| 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
| 10 | $GIT_DIR/hooks/* |
| 11 | |
| 12 | |
| 13 | DESCRIPTION |
| 14 | ----------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 15 | |
| 16 | Hooks are little scripts you can place in `$GIT_DIR/hooks` |
| 17 | directory to trigger action at certain points. When |
Junio C Hamano | 6efe302 | 2009-01-13 16:47:56 | [diff] [blame] | 18 | 'git-init' is run, a handful of example hooks are copied into the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 19 | `hooks` directory of the new repository, but by default they are |
Junio C Hamano | 6aff399 | 2008-06-25 08:07:44 | [diff] [blame] | 20 | all disabled. To enable a hook, rename it by removing its `.sample` |
| 21 | suffix. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 22 | |
Junio C Hamano | 8a48fa2 | 2008-12-18 08:44:30 | [diff] [blame] | 23 | NOTE: It is also a requirement for a given hook to be executable. |
| 24 | However - in a freshly initialized repository - the `.sample` files are |
| 25 | executable by default. |
| 26 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 27 | This document describes the currently defined hooks. |
| 28 | |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 29 | HOOKS |
| 30 | ----- |
| 31 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 32 | applypatch-msg |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 33 | ~~~~~~~~~~~~~~ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 34 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 35 | This hook is invoked by 'git-am' script. It takes a single |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 36 | parameter, the name of the file that holds the proposed commit |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 37 | log message. Exiting with non-zero status causes |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 38 | 'git-am' to abort before applying the patch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 39 | |
| 40 | The hook is allowed to edit the message file in place, and can |
| 41 | be used to normalize the message into some project standard |
| 42 | format (if the project has one). It can also be used to refuse |
| 43 | the commit after inspecting the message file. |
| 44 | |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 45 | The default 'applypatch-msg' hook, when enabled, runs the |
| 46 | 'commit-msg' hook, if the latter is enabled. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 47 | |
| 48 | pre-applypatch |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 49 | ~~~~~~~~~~~~~~ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 50 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 51 | This hook is invoked by 'git-am'. It takes no parameter, and is |
Junio C Hamano | a31092a | 2008-05-04 06:41:23 | [diff] [blame] | 52 | invoked after the patch is applied, but before a commit is made. |
| 53 | |
| 54 | If it exits with non-zero status, then the working tree will not be |
| 55 | committed after applying the patch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 56 | |
| 57 | It can be used to inspect the current working tree and refuse to |
| 58 | make a commit if it does not pass certain test. |
| 59 | |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 60 | The default 'pre-applypatch' hook, when enabled, runs the |
| 61 | 'pre-commit' hook, if the latter is enabled. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 62 | |
| 63 | post-applypatch |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 64 | ~~~~~~~~~~~~~~~ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 65 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 66 | This hook is invoked by 'git-am'. It takes no parameter, |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 67 | and is invoked after the patch is applied and a commit is made. |
| 68 | |
| 69 | This hook is meant primarily for notification, and cannot affect |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 70 | the outcome of 'git-am'. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 71 | |
| 72 | pre-commit |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 73 | ~~~~~~~~~~ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 74 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 75 | This hook is invoked by 'git-commit', and can be bypassed |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 76 | with `\--no-verify` option. It takes no parameter, and is |
| 77 | invoked before obtaining the proposed commit log message and |
| 78 | making a commit. Exiting with non-zero status from this script |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 79 | causes the 'git-commit' to abort. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 80 | |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 81 | The default 'pre-commit' hook, when enabled, catches introduction |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 82 | of lines with trailing whitespaces and aborts the commit when |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 83 | such a line is found. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 84 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 85 | All the 'git-commit' hooks are invoked with the environment |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 86 | variable `GIT_EDITOR=:` if the command will not bring up an editor |
| 87 | to modify the commit message. |
| 88 | |
| 89 | prepare-commit-msg |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 90 | ~~~~~~~~~~~~~~~~~~ |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 91 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 92 | This hook is invoked by 'git-commit' right after preparing the |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 93 | default log message, and before the editor is started. |
| 94 | |
| 95 | 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] | 96 | 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] | 97 | message, and can be: `message` (if a `-m` or `-F` option was |
| 98 | given); `template` (if a `-t` option was given or the |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 99 | configuration option `commit.template` is set); `merge` (if the |
| 100 | commit is a merge or a `.git/MERGE_MSG` file exists); `squash` |
| 101 | (if a `.git/SQUASH_MSG` file exists); or `commit`, followed by |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 102 | a commit SHA1 (if a `-c`, `-C` or `\--amend` option was given). |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 103 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 104 | If the exit status is non-zero, 'git-commit' will abort. |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 105 | |
| 106 | The purpose of the hook is to edit the message file in place, and |
| 107 | it is not suppressed by the `\--no-verify` option. A non-zero exit |
| 108 | means a failure of the hook and aborts the commit. It should not |
| 109 | be used as replacement for pre-commit hook. |
| 110 | |
| 111 | The sample `prepare-commit-msg` hook that comes with git comments |
| 112 | out the `Conflicts:` part of a merge's commit message. |
| 113 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 114 | commit-msg |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 115 | ~~~~~~~~~~ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 116 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 117 | This hook is invoked by 'git-commit', and can be bypassed |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 118 | with `\--no-verify` option. It takes a single parameter, the |
| 119 | name of the file that holds the proposed commit log message. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 120 | Exiting with non-zero status causes the 'git-commit' to |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 121 | abort. |
| 122 | |
| 123 | The hook is allowed to edit the message file in place, and can |
| 124 | be used to normalize the message into some project standard |
| 125 | format (if the project has one). It can also be used to refuse |
| 126 | the commit after inspecting the message file. |
| 127 | |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 128 | The default 'commit-msg' hook, when enabled, detects duplicate |
| 129 | "Signed-off-by" lines, and aborts the commit if one is found. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 130 | |
| 131 | post-commit |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 132 | ~~~~~~~~~~~ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 133 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 134 | This hook is invoked by 'git-commit'. It takes no |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 135 | parameter, and is invoked after a commit is made. |
| 136 | |
| 137 | This hook is meant primarily for notification, and cannot affect |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 138 | the outcome of 'git-commit'. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 139 | |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 140 | pre-rebase |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 141 | ~~~~~~~~~~ |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 142 | |
| 143 | This hook is called by 'git-rebase' and can be used to prevent a branch |
| 144 | from getting rebased. |
| 145 | |
| 146 | |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 147 | post-checkout |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 148 | ~~~~~~~~~~~~~ |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 149 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 150 | This hook is invoked when a 'git-checkout' is run after having updated the |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 151 | worktree. The hook is given three parameters: the ref of the previous HEAD, |
| 152 | the ref of the new HEAD (which may or may not have changed), and a flag |
| 153 | indicating whether the checkout was a branch checkout (changing branches, |
| 154 | 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] | 155 | This hook cannot affect the outcome of 'git-checkout'. |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 156 | |
Junio C Hamano | 36a5672 | 2009-03-28 08:55:34 | [diff] [blame] | 157 | It is also run after 'git-clone', unless the --no-checkout (-n) option is |
| 158 | used. The first parameter given to the hook is the null-ref, the second the |
| 159 | ref of the new HEAD and the flag is always 1. |
| 160 | |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 161 | This hook can be used to perform repository validity checks, auto-display |
| 162 | differences from the previous HEAD if different, or set working dir metadata |
| 163 | properties. |
| 164 | |
Junio C Hamano | 01d8f83 | 2007-09-24 07:37:30 | [diff] [blame] | 165 | post-merge |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 166 | ~~~~~~~~~~ |
Junio C Hamano | 01d8f83 | 2007-09-24 07:37:30 | [diff] [blame] | 167 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 168 | This hook is invoked by 'git-merge', which happens when a 'git-pull' |
Junio C Hamano | 01d8f83 | 2007-09-24 07:37:30 | [diff] [blame] | 169 | is done on a local repository. The hook takes a single parameter, a status |
| 170 | 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] | 171 | This hook cannot affect the outcome of 'git-merge' and is not executed, |
Junio C Hamano | 47d68a5 | 2008-05-06 06:35:40 | [diff] [blame] | 172 | if the merge failed due to conflicts. |
Junio C Hamano | 01d8f83 | 2007-09-24 07:37:30 | [diff] [blame] | 173 | |
| 174 | This hook can be used in conjunction with a corresponding pre-commit hook to |
| 175 | save and restore any form of metadata associated with the working tree |
| 176 | (eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl |
| 177 | for an example of how to do this. |
| 178 | |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 179 | [[pre-receive]] |
| 180 | pre-receive |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 181 | ~~~~~~~~~~~ |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 182 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 183 | This hook is invoked by 'git-receive-pack' on the remote repository, |
| 184 | which happens when a 'git-push' is done on a local repository. |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 185 | Just before starting to update refs on the remote repository, the |
| 186 | pre-receive hook is invoked. Its exit status determines the success |
| 187 | or failure of the update. |
| 188 | |
| 189 | This hook executes once for the receive operation. It takes no |
| 190 | arguments, but for each ref to be updated it receives on standard |
| 191 | input a line of the format: |
| 192 | |
| 193 | <old-value> SP <new-value> SP <ref-name> LF |
| 194 | |
| 195 | where `<old-value>` is the old object name stored in the ref, |
| 196 | `<new-value>` is the new object name to be stored in the ref and |
| 197 | `<ref-name>` is the full name of the ref. |
| 198 | When creating a new ref, `<old-value>` is 40 `0`. |
| 199 | |
| 200 | If the hook exits with non-zero status, none of the refs will be |
| 201 | updated. If the hook exits with zero, updating of individual refs can |
| 202 | still be prevented by the <<update,'update'>> hook. |
| 203 | |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 204 | Both standard output and standard error output are forwarded to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 205 | 'git-send-pack' on the other end, so you can simply `echo` messages |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 206 | for the user. |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 207 | |
| 208 | [[update]] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 209 | update |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 210 | ~~~~~~ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 211 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 212 | This hook is invoked by 'git-receive-pack' on the remote repository, |
| 213 | which happens when a 'git-push' is done on a local repository. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 214 | Just before updating the ref on the remote repository, the update hook |
Junio C Hamano | 33db437 | 2006-06-07 19:51:45 | [diff] [blame] | 215 | is invoked. Its exit status determines the success or failure of |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 216 | the ref update. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 217 | |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 218 | The hook executes once for each ref to be updated, and takes |
| 219 | three parameters: |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 220 | |
| 221 | - the name of the ref being updated, |
| 222 | - the old object name stored in the ref, |
| 223 | - and the new objectname to be stored in the ref. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 224 | |
| 225 | A zero exit from the update hook allows the ref to be updated. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 226 | Exiting with a non-zero status prevents 'git-receive-pack' |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 227 | from updating that ref. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 228 | |
| 229 | This hook can be used to prevent 'forced' update on certain refs by |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 230 | making sure that the object name is a commit object that is a |
| 231 | descendant of the commit object named by the old object name. |
Junio C Hamano | 3f680f3 | 2009-11-16 02:10:54 | [diff] [blame^] | 232 | That is, to enforce a "fast-forward only" policy. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 233 | |
| 234 | It could also be used to log the old..new status. However, it |
| 235 | 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] | 236 | firing one e-mail per ref when used naively, though. The |
| 237 | <<post-receive,'post-receive'>> hook is more suited to that. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 238 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 239 | Another use suggested on the mailing list is to use this hook to |
| 240 | implement access control which is finer grained than the one |
| 241 | based on filesystem group. |
| 242 | |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 243 | Both standard output and standard error output are forwarded to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 244 | 'git-send-pack' on the other end, so you can simply `echo` messages |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 245 | for the user. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 246 | |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 247 | The default 'update' hook, when enabled--and with |
Junio C Hamano | d6fff40 | 2009-09-14 09:40:50 | [diff] [blame] | 248 | `hooks.allowunannotated` config option unset or set to false--prevents |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 249 | unannotated tags to be pushed. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 250 | |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 251 | [[post-receive]] |
| 252 | post-receive |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 253 | ~~~~~~~~~~~~ |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 254 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 255 | This hook is invoked by 'git-receive-pack' on the remote repository, |
| 256 | which happens when a 'git-push' is done on a local repository. |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 257 | It executes on the remote repository once after all the refs have |
| 258 | been updated. |
| 259 | |
| 260 | This hook executes once for the receive operation. It takes no |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 261 | arguments, but gets the same information as the |
| 262 | <<pre-receive,'pre-receive'>> |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 263 | hook does on its standard input. |
| 264 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 265 | This hook does not affect the outcome of 'git-receive-pack', as it |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 266 | is called after the real work is done. |
| 267 | |
Junio C Hamano | a638742 | 2007-08-25 03:54:27 | [diff] [blame] | 268 | This supersedes the <<post-update,'post-update'>> hook in that it gets |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 269 | both old and new values of all the refs in addition to their |
| 270 | names. |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 271 | |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 272 | Both standard output and standard error output are forwarded to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 273 | 'git-send-pack' on the other end, so you can simply `echo` messages |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 274 | for the user. |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 275 | |
| 276 | The default 'post-receive' hook is empty, but there is |
| 277 | a sample script `post-receive-email` provided in the `contrib/hooks` |
| 278 | directory in git distribution, which implements sending commit |
| 279 | emails. |
| 280 | |
| 281 | [[post-update]] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 282 | post-update |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 283 | ~~~~~~~~~~~ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 284 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 285 | This hook is invoked by 'git-receive-pack' on the remote repository, |
| 286 | which happens when a 'git-push' is done on a local repository. |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 287 | It executes on the remote repository once after all the refs have |
| 288 | been updated. |
| 289 | |
| 290 | It takes a variable number of parameters, each of which is the |
| 291 | name of ref that was actually updated. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 292 | |
| 293 | This hook is meant primarily for notification, and cannot affect |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 294 | the outcome of 'git-receive-pack'. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 295 | |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 296 | The 'post-update' hook can tell what are the heads that were pushed, |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 297 | but it does not know what their original and updated values are, |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 298 | so it is a poor place to do log old..new. The |
| 299 | <<post-receive,'post-receive'>> hook does get both original and |
| 300 | updated values of the refs. You might consider it instead if you need |
| 301 | them. |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 302 | |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 303 | When enabled, the default 'post-update' hook runs |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 304 | 'git-update-server-info' to keep the information used by dumb |
Junio C Hamano | d578413 | 2006-09-20 21:29:27 | [diff] [blame] | 305 | transports (e.g., HTTP) up-to-date. If you are publishing |
| 306 | a git repository that is accessible via HTTP, you should |
Junio C Hamano | 818f7d6 | 2006-03-26 01:49:30 | [diff] [blame] | 307 | probably enable this hook. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 308 | |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 309 | Both standard output and standard error output are forwarded to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 310 | 'git-send-pack' on the other end, so you can simply `echo` messages |
Junio C Hamano | 323e52d | 2007-05-13 22:19:53 | [diff] [blame] | 311 | for the user. |
Junio C Hamano | e3ddb5b | 2008-04-21 00:48:07 | [diff] [blame] | 312 | |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 313 | post-upload-pack |
| 314 | ---------------- |
| 315 | |
| 316 | After upload-pack successfully finishes its operation, this hook is called |
| 317 | for logging purposes. |
| 318 | |
| 319 | The hook is passed various pieces of information, one per line, from its |
| 320 | standard input. Currently the following items can be fed to the hook, but |
| 321 | more types of information may be added in the future: |
| 322 | |
| 323 | want SHA-1:: |
| 324 | 40-byte hexadecimal object name the client asked to include in the |
| 325 | resulting pack. Can occur one or more times in the input. |
| 326 | |
| 327 | have SHA-1:: |
| 328 | 40-byte hexadecimal object name the client asked to exclude from |
| 329 | the resulting pack, claiming to have them already. Can occur zero |
| 330 | or more times in the input. |
| 331 | |
| 332 | time float:: |
| 333 | Number of seconds spent for creating the packfile. |
| 334 | |
| 335 | size decimal:: |
| 336 | Size of the resulting packfile in bytes. |
| 337 | |
| 338 | kind string: |
| 339 | Either "clone" (when the client did not give us any "have", and asked |
| 340 | for all our refs with "want"), or "fetch" (otherwise). |
| 341 | |
Junio C Hamano | e3ddb5b | 2008-04-21 00:48:07 | [diff] [blame] | 342 | pre-auto-gc |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 343 | ~~~~~~~~~~~ |
Junio C Hamano | e3ddb5b | 2008-04-21 00:48:07 | [diff] [blame] | 344 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 345 | This hook is invoked by 'git-gc --auto'. It takes no parameter, and |
| 346 | exiting with non-zero status from this script causes the 'git-gc --auto' |
Junio C Hamano | e3ddb5b | 2008-04-21 00:48:07 | [diff] [blame] | 347 | to abort. |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 348 | |
| 349 | GIT |
| 350 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 351 | Part of the linkgit:git[1] suite |