blob: 50365f2914e04fe26969f00d3745e171375779db [file] [log] [blame]
Junio C Hamano2fbcd212008-05-14 22:26:071githooks(5)
2===========
3
4NAME
5----
Junio C Hamano076ffcc2013-02-06 05:13:216githooks - Hooks used by Git
Junio C Hamano2fbcd212008-05-14 22:26:077
8SYNOPSIS
9--------
Junio C Hamano198b1f12016-05-17 22:27:2410$GIT_DIR/hooks/* (or \`git config core.hooksPath`/*)
Junio C Hamano2fbcd212008-05-14 22:26:0711
12
13DESCRIPTION
14-----------
Junio C Hamano1a4e8412005-12-27 08:17:2315
Junio C Hamano198b1f12016-05-17 22:27:2416Hooks are programs you can place in a hooks directory to trigger
17actions at certain points in git's execution. Hooks that don't have
18the executable bit set are ignored.
Junio C Hamano1a4e8412005-12-27 08:17:2319
Junio C Hamano198b1f12016-05-17 22:27:2420By default the hooks directory is `$GIT_DIR/hooks`, but that can be
21changed via the `core.hooksPath` configuration variable (see
22linkgit:git-config[1]).
Junio C Hamano8a48fa22008-12-18 08:44:3023
Junio C Hamano198b1f12016-05-17 22:27:2424Before Git invokes a hook, it changes its working directory to either
Junio C Hamano4c60d9a2017-05-04 14:36:2225$GIT_DIR in a bare repository or the root of the working tree in a non-bare
26repository. An exception are hooks triggered during a push ('pre-receive',
27'update', 'post-receive', 'post-update', 'push-to-checkout') which are always
28executed in $GIT_DIR.
Junio C Hamano198b1f12016-05-17 22:27:2429
30Hooks can get their arguments via the environment, command-line
31arguments, and stdin. See the documentation for each hook below for
32details.
33
Junio C Hamanob9d9d902018-05-23 07:07:4234`git init` may copy hooks to the new repository, depending on its
Junio C Hamano198b1f12016-05-17 22:27:2435configuration. See the "TEMPLATE DIRECTORY" section in
36linkgit:git-init[1] for details. When the rest of this document refers
37to "default hooks" it's talking about the default template shipped
38with Git.
39
40The currently supported hooks are described below.
Junio C Hamano1a4e8412005-12-27 08:17:2341
Junio C Hamanoc28068f2009-09-08 00:55:2342HOOKS
43-----
44
Junio C Hamano1a4e8412005-12-27 08:17:2345applypatch-msg
Junio C Hamanoc28068f2009-09-08 00:55:2346~~~~~~~~~~~~~~
Junio C Hamano1a4e8412005-12-27 08:17:2347
Junio C Hamanob9d9d902018-05-23 07:07:4248This hook is invoked by linkgit:git-am[1]. It takes a single
Junio C Hamano1a4e8412005-12-27 08:17:2349parameter, the name of the file that holds the proposed commit
Junio C Hamanob9d9d902018-05-23 07:07:4250log message. Exiting with a non-zero status causes `git am` to abort
Junio C Hamano198b1f12016-05-17 22:27:2451before applying the patch.
Junio C Hamano1a4e8412005-12-27 08:17:2352
53The hook is allowed to edit the message file in place, and can
54be used to normalize the message into some project standard
Junio C Hamano198b1f12016-05-17 22:27:2455format. It can also be used to refuse the commit after inspecting
56the message file.
Junio C Hamano1a4e8412005-12-27 08:17:2357
Junio C Hamanod5784132006-09-20 21:29:2758The default 'applypatch-msg' hook, when enabled, runs the
59'commit-msg' hook, if the latter is enabled.
Junio C Hamano1a4e8412005-12-27 08:17:2360
61pre-applypatch
Junio C Hamanoc28068f2009-09-08 00:55:2362~~~~~~~~~~~~~~
Junio C Hamano1a4e8412005-12-27 08:17:2363
Junio C Hamanob9d9d902018-05-23 07:07:4264This hook is invoked by linkgit:git-am[1]. It takes no parameter, and is
Junio C Hamanoa31092a2008-05-04 06:41:2365invoked after the patch is applied, but before a commit is made.
66
67If it exits with non-zero status, then the working tree will not be
68committed after applying the patch.
Junio C Hamano1a4e8412005-12-27 08:17:2369
70It can be used to inspect the current working tree and refuse to
71make a commit if it does not pass certain test.
72
Junio C Hamanod5784132006-09-20 21:29:2773The default 'pre-applypatch' hook, when enabled, runs the
74'pre-commit' hook, if the latter is enabled.
Junio C Hamano1a4e8412005-12-27 08:17:2375
76post-applypatch
Junio C Hamanoc28068f2009-09-08 00:55:2377~~~~~~~~~~~~~~~
Junio C Hamano1a4e8412005-12-27 08:17:2378
Junio C Hamanob9d9d902018-05-23 07:07:4279This hook is invoked by linkgit:git-am[1]. It takes no parameter,
Junio C Hamano1a4e8412005-12-27 08:17:2380and is invoked after the patch is applied and a commit is made.
81
82This hook is meant primarily for notification, and cannot affect
Junio C Hamanob9d9d902018-05-23 07:07:4283the outcome of `git am`.
Junio C Hamano1a4e8412005-12-27 08:17:2384
85pre-commit
Junio C Hamanoc28068f2009-09-08 00:55:2386~~~~~~~~~~
Junio C Hamano1a4e8412005-12-27 08:17:2387
Junio C Hamanob9d9d902018-05-23 07:07:4288This hook is invoked by linkgit:git-commit[1], and can be bypassed
Junio C Hamano198b1f12016-05-17 22:27:2489with the `--no-verify` option. It takes no parameters, and is
Junio C Hamano1a4e8412005-12-27 08:17:2390invoked before obtaining the proposed commit log message and
Junio C Hamano198b1f12016-05-17 22:27:2491making a commit. Exiting with a non-zero status from this script
Junio C Hamanob9d9d902018-05-23 07:07:4292causes the `git commit` command to abort before creating a commit.
Junio C Hamano1a4e8412005-12-27 08:17:2393
Junio C Hamanod5784132006-09-20 21:29:2794The default 'pre-commit' hook, when enabled, catches introduction
Junio C Hamano1a4e8412005-12-27 08:17:2395of lines with trailing whitespaces and aborts the commit when
Junio C Hamanod5784132006-09-20 21:29:2796such a line is found.
Junio C Hamano1a4e8412005-12-27 08:17:2397
Junio C Hamanob9d9d902018-05-23 07:07:4298All the `git commit` hooks are invoked with the environment
Junio C Hamano26e590a2008-02-17 03:53:5199variable `GIT_EDITOR=:` if the command will not bring up an editor
100to modify the commit message.
101
Junio C Hamano11f15372019-03-07 03:17:00102The default 'pre-commit' hook, when enabled--and with the
103`hooks.allownonascii` config option unset or set to false--prevents
104the use of non-ASCII filenames.
105
Junio C Hamanocb705392019-09-18 19:30:01106pre-merge-commit
107~~~~~~~~~~~~~~~~
108
109This hook is invoked by linkgit:git-merge[1], and can be bypassed
110with the `--no-verify` option. It takes no parameters, and is
111invoked after the merge has been carried out successfully and before
112obtaining the proposed commit log message to
113make a commit. Exiting with a non-zero status from this script
114causes the `git merge` command to abort before creating a commit.
115
116The default 'pre-merge-commit' hook, when enabled, runs the
117'pre-commit' hook, if the latter is enabled.
118
119This hook is invoked with the environment variable
120`GIT_EDITOR=:` if the command will not bring up an editor
121to modify the commit message.
122
123If the merge cannot be carried out automatically, the conflicts
124need to be resolved and the result committed separately (see
125linkgit:git-merge[1]). At that point, this hook will not be executed,
126but the 'pre-commit' hook will, if it is enabled.
127
Junio C Hamano26e590a2008-02-17 03:53:51128prepare-commit-msg
Junio C Hamanoc28068f2009-09-08 00:55:23129~~~~~~~~~~~~~~~~~~
Junio C Hamano26e590a2008-02-17 03:53:51130
Junio C Hamanob9d9d902018-05-23 07:07:42131This hook is invoked by linkgit:git-commit[1] right after preparing the
Junio C Hamano26e590a2008-02-17 03:53:51132default log message, and before the editor is started.
133
134It takes one to three parameters. The first is the name of the file
Junio C Hamanobd53dbf2009-01-18 18:26:37135that contains the commit log message. The second is the source of the commit
Junio C Hamanoa476efa2008-10-10 15:31:42136message, and can be: `message` (if a `-m` or `-F` option was
137given); `template` (if a `-t` option was given or the
Junio C Hamano26e590a2008-02-17 03:53:51138configuration option `commit.template` is set); `merge` (if the
139commit is a merge or a `.git/MERGE_MSG` file exists); `squash`
140(if a `.git/SQUASH_MSG` file exists); or `commit`, followed by
Junio C Hamanoe3f080d2013-04-22 02:27:13141a commit SHA-1 (if a `-c`, `-C` or `--amend` option was given).
Junio C Hamano26e590a2008-02-17 03:53:51142
Junio C Hamanob9d9d902018-05-23 07:07:42143If the exit status is non-zero, `git commit` will abort.
Junio C Hamano26e590a2008-02-17 03:53:51144
145The purpose of the hook is to edit the message file in place, and
Junio C Hamanob76a6862012-05-02 22:02:46146it is not suppressed by the `--no-verify` option. A non-zero exit
Junio C Hamano26e590a2008-02-17 03:53:51147means a failure of the hook and aborts the commit. It should not
148be used as replacement for pre-commit hook.
149
Junio C Hamano4b2a6c12017-08-22 18:32:37150The sample `prepare-commit-msg` hook that comes with Git removes the
151help message found in the commented portion of the commit template.
Junio C Hamano26e590a2008-02-17 03:53:51152
Junio C Hamano1a4e8412005-12-27 08:17:23153commit-msg
Junio C Hamanoc28068f2009-09-08 00:55:23154~~~~~~~~~~
Junio C Hamano1a4e8412005-12-27 08:17:23155
Junio C Hamanob9d9d902018-05-23 07:07:42156This hook is invoked by linkgit:git-commit[1] and linkgit:git-merge[1], and can be
Junio C Hamanoef75f372017-09-29 04:22:33157bypassed with the `--no-verify` option. It takes a single parameter,
158the name of the file that holds the proposed commit log message.
159Exiting with a non-zero status causes the command to abort.
Junio C Hamano1a4e8412005-12-27 08:17:23160
Junio C Hamano198b1f12016-05-17 22:27:24161The hook is allowed to edit the message file in place, and can be used
162to normalize the message into some project standard format. It
163can also be used to refuse the commit after inspecting the message
164file.
Junio C Hamano1a4e8412005-12-27 08:17:23165
Junio C Hamanod5784132006-09-20 21:29:27166The default 'commit-msg' hook, when enabled, detects duplicate
167"Signed-off-by" lines, and aborts the commit if one is found.
Junio C Hamano1a4e8412005-12-27 08:17:23168
169post-commit
Junio C Hamanoc28068f2009-09-08 00:55:23170~~~~~~~~~~~
Junio C Hamano1a4e8412005-12-27 08:17:23171
Junio C Hamanob9d9d902018-05-23 07:07:42172This hook is invoked by linkgit:git-commit[1]. It takes no parameters, and is
Junio C Hamano198b1f12016-05-17 22:27:24173invoked after a commit is made.
Junio C Hamano1a4e8412005-12-27 08:17:23174
175This hook is meant primarily for notification, and cannot affect
Junio C Hamanob9d9d902018-05-23 07:07:42176the outcome of `git commit`.
Junio C Hamano1a4e8412005-12-27 08:17:23177
Junio C Hamanoa476efa2008-10-10 15:31:42178pre-rebase
Junio C Hamanoc28068f2009-09-08 00:55:23179~~~~~~~~~~
Junio C Hamanoa476efa2008-10-10 15:31:42180
Junio C Hamanob9d9d902018-05-23 07:07:42181This hook is called by linkgit:git-rebase[1] and can be used to prevent a
Junio C Hamano947ab822013-03-19 23:07:29182branch from getting rebased. The hook may be called with one or
183two parameters. The first parameter is the upstream from which
184the series was forked. The second parameter is the branch being
185rebased, and is not set when rebasing the current branch.
Junio C Hamanoa476efa2008-10-10 15:31:42186
Junio C Hamano1b50ce92007-10-03 12:05:53187post-checkout
Junio C Hamanoc28068f2009-09-08 00:55:23188~~~~~~~~~~~~~
Junio C Hamano1b50ce92007-10-03 12:05:53189
Junio C Hamanoc9f11c22019-07-10 02:54:04190This hook is invoked when a linkgit:git-checkout[1] or
191linkgit:git-switch[1] is run after having updated the
Junio C Hamano1b50ce92007-10-03 12:05:53192worktree. The hook is given three parameters: the ref of the previous HEAD,
193the ref of the new HEAD (which may or may not have changed), and a flag
194indicating whether the checkout was a branch checkout (changing branches,
195flag=1) or a file checkout (retrieving a file from the index, flag=0).
Junio C Hamanoc9f11c22019-07-10 02:54:04196This hook cannot affect the outcome of `git switch` or `git checkout`.
Junio C Hamano1b50ce92007-10-03 12:05:53197
Junio C Hamanob9d9d902018-05-23 07:07:42198It is also run after linkgit:git-clone[1], unless the `--no-checkout` (`-n`) option is
Junio C Hamano36a56722009-03-28 08:55:34199used. The first parameter given to the hook is the null-ref, the second the
Junio C Hamanob9d9d902018-05-23 07:07:42200ref of the new HEAD and the flag is always 1. Likewise for `git worktree add`
201unless `--no-checkout` is used.
Junio C Hamano36a56722009-03-28 08:55:34202
Junio C Hamano1b50ce92007-10-03 12:05:53203This hook can be used to perform repository validity checks, auto-display
204differences from the previous HEAD if different, or set working dir metadata
205properties.
206
Junio C Hamano01d8f832007-09-24 07:37:30207post-merge
Junio C Hamanoc28068f2009-09-08 00:55:23208~~~~~~~~~~
Junio C Hamano01d8f832007-09-24 07:37:30209
Junio C Hamanob9d9d902018-05-23 07:07:42210This hook is invoked by linkgit:git-merge[1], which happens when a `git pull`
Junio C Hamano01d8f832007-09-24 07:37:30211is done on a local repository. The hook takes a single parameter, a status
212flag specifying whether or not the merge being done was a squash merge.
Junio C Hamanob9d9d902018-05-23 07:07:42213This hook cannot affect the outcome of `git merge` and is not executed,
Junio C Hamano47d68a52008-05-06 06:35:40214if the merge failed due to conflicts.
Junio C Hamano01d8f832007-09-24 07:37:30215
216This hook can be used in conjunction with a corresponding pre-commit hook to
217save and restore any form of metadata associated with the working tree
Junio C Hamanofb5ffde2014-11-04 22:38:56218(e.g.: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl
Junio C Hamano01d8f832007-09-24 07:37:30219for an example of how to do this.
220
Junio C Hamano36d52292013-01-25 21:32:36221pre-push
222~~~~~~~~
223
Junio C Hamanob9d9d902018-05-23 07:07:42224This hook is called by linkgit:git-push[1] and can be used to prevent
225a push from taking place. The hook is called with two parameters
226which provide the name and location of the destination remote, if a
227named remote is not being used both values will be the same.
Junio C Hamano36d52292013-01-25 21:32:36228
229Information about what is to be pushed is provided on the hook's standard
230input with lines of the form:
231
232 <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF
233
234For instance, if the command +git push origin master:foreign+ were run the
235hook would receive a line like the following:
236
237 refs/heads/master 67890 refs/heads/foreign 12345
238
Junio C Hamanoe3f080d2013-04-22 02:27:13239although the full, 40-character SHA-1s would be supplied. If the foreign ref
240does not yet exist the `<remote SHA-1>` will be 40 `0`. If a ref is to be
Junio C Hamano36d52292013-01-25 21:32:36241deleted, the `<local ref>` will be supplied as `(delete)` and the `<local
Junio C Hamanoe3f080d2013-04-22 02:27:13242SHA-1>` will be 40 `0`. If the local commit was specified by something other
243than a name which could be expanded (such as `HEAD~`, or a SHA-1) it will be
Junio C Hamano36d52292013-01-25 21:32:36244supplied as it was originally given.
245
Junio C Hamanob9d9d902018-05-23 07:07:42246If this hook exits with a non-zero status, `git push` will abort without
Junio C Hamano36d52292013-01-25 21:32:36247pushing anything. Information about why the push is rejected may be sent
248to the user by writing to standard error.
249
Junio C Hamano8638c922007-05-12 20:50:08250[[pre-receive]]
251pre-receive
Junio C Hamanoc28068f2009-09-08 00:55:23252~~~~~~~~~~~
Junio C Hamano8638c922007-05-12 20:50:08253
Junio C Hamanob9d9d902018-05-23 07:07:42254This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
255`git push` and updates reference(s) in its repository.
Junio C Hamano8638c922007-05-12 20:50:08256Just before starting to update refs on the remote repository, the
257pre-receive hook is invoked. Its exit status determines the success
258or failure of the update.
259
260This hook executes once for the receive operation. It takes no
261arguments, but for each ref to be updated it receives on standard
262input a line of the format:
263
264 <old-value> SP <new-value> SP <ref-name> LF
265
266where `<old-value>` is the old object name stored in the ref,
267`<new-value>` is the new object name to be stored in the ref and
268`<ref-name>` is the full name of the ref.
269When creating a new ref, `<old-value>` is 40 `0`.
270
271If the hook exits with non-zero status, none of the refs will be
272updated. If the hook exits with zero, updating of individual refs can
273still be prevented by the <<update,'update'>> hook.
274
Junio C Hamano323e52d2007-05-13 22:19:53275Both standard output and standard error output are forwarded to
Junio C Hamanob9d9d902018-05-23 07:07:42276`git send-pack` on the other end, so you can simply `echo` messages
Junio C Hamano323e52d2007-05-13 22:19:53277for the user.
Junio C Hamano8638c922007-05-12 20:50:08278
Junio C Hamanoe48a1132016-08-03 22:40:21279The number of push options given on the command line of
280`git push --push-option=...` can be read from the environment
281variable `GIT_PUSH_OPTION_COUNT`, and the options themselves are
282found in `GIT_PUSH_OPTION_0`, `GIT_PUSH_OPTION_1`,...
283If it is negotiated to not use the push options phase, the
284environment variables will not be set. If the client selects
285to use push options, but doesn't transmit any, the count variable
286will be set to zero, `GIT_PUSH_OPTION_COUNT=0`.
287
Junio C Hamanoe25cc812017-04-24 06:17:43288See the section on "Quarantine Environment" in
289linkgit:git-receive-pack[1] for some caveats.
290
Junio C Hamano8638c922007-05-12 20:50:08291[[update]]
Junio C Hamano1a4e8412005-12-27 08:17:23292update
Junio C Hamanoc28068f2009-09-08 00:55:23293~~~~~~
Junio C Hamano1a4e8412005-12-27 08:17:23294
Junio C Hamanob9d9d902018-05-23 07:07:42295This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
296`git push` and updates reference(s) in its repository.
Junio C Hamano818f7d62006-03-26 01:49:30297Just before updating the ref on the remote repository, the update hook
Junio C Hamano33db4372006-06-07 19:51:45298is invoked. Its exit status determines the success or failure of
Junio C Hamano818f7d62006-03-26 01:49:30299the ref update.
Junio C Hamano1a4e8412005-12-27 08:17:23300
Junio C Hamano818f7d62006-03-26 01:49:30301The hook executes once for each ref to be updated, and takes
302three parameters:
Junio C Hamanod5784132006-09-20 21:29:27303
304 - the name of the ref being updated,
305 - the old object name stored in the ref,
Junio C Hamano826f5c42014-02-07 20:33:30306 - and the new object name to be stored in the ref.
Junio C Hamano818f7d62006-03-26 01:49:30307
308A zero exit from the update hook allows the ref to be updated.
Junio C Hamanob9d9d902018-05-23 07:07:42309Exiting with a non-zero status prevents `git receive-pack`
Junio C Hamano8638c922007-05-12 20:50:08310from updating that ref.
Junio C Hamano818f7d62006-03-26 01:49:30311
312This hook can be used to prevent 'forced' update on certain refs by
Junio C Hamano1a4e8412005-12-27 08:17:23313making sure that the object name is a commit object that is a
314descendant of the commit object named by the old object name.
Junio C Hamano3f680f32009-11-16 02:10:54315That is, to enforce a "fast-forward only" policy.
Junio C Hamano818f7d62006-03-26 01:49:30316
317It could also be used to log the old..new status. However, it
318does not know the entire set of branches, so it would end up
Junio C Hamano8638c922007-05-12 20:50:08319firing one e-mail per ref when used naively, though. The
320<<post-receive,'post-receive'>> hook is more suited to that.
Junio C Hamano818f7d62006-03-26 01:49:30321
Junio C Hamano198b1f12016-05-17 22:27:24322In an environment that restricts the users' access only to git
323commands over the wire, this hook can be used to implement access
324control without relying on filesystem ownership and group
325membership. See linkgit:git-shell[1] for how you might use the login
326shell to restrict the user's access to only git commands.
Junio C Hamano1a4e8412005-12-27 08:17:23327
Junio C Hamano323e52d2007-05-13 22:19:53328Both standard output and standard error output are forwarded to
Junio C Hamanob9d9d902018-05-23 07:07:42329`git send-pack` on the other end, so you can simply `echo` messages
Junio C Hamano323e52d2007-05-13 22:19:53330for the user.
Junio C Hamano1a4e8412005-12-27 08:17:23331
Junio C Hamano8638c922007-05-12 20:50:08332The default 'update' hook, when enabled--and with
Junio C Hamanod6fff402009-09-14 09:40:50333`hooks.allowunannotated` config option unset or set to false--prevents
Junio C Hamano8638c922007-05-12 20:50:08334unannotated tags to be pushed.
Junio C Hamano818f7d62006-03-26 01:49:30335
Junio C Hamano8638c922007-05-12 20:50:08336[[post-receive]]
337post-receive
Junio C Hamanoc28068f2009-09-08 00:55:23338~~~~~~~~~~~~
Junio C Hamano8638c922007-05-12 20:50:08339
Junio C Hamanob9d9d902018-05-23 07:07:42340This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
341`git push` and updates reference(s) in its repository.
Junio C Hamano8638c922007-05-12 20:50:08342It executes on the remote repository once after all the refs have
343been updated.
344
345This hook executes once for the receive operation. It takes no
Junio C Hamano323e52d2007-05-13 22:19:53346arguments, but gets the same information as the
347<<pre-receive,'pre-receive'>>
Junio C Hamano8638c922007-05-12 20:50:08348hook does on its standard input.
349
Junio C Hamanob9d9d902018-05-23 07:07:42350This hook does not affect the outcome of `git receive-pack`, as it
Junio C Hamano8638c922007-05-12 20:50:08351is called after the real work is done.
352
Junio C Hamanoa6387422007-08-25 03:54:27353This supersedes the <<post-update,'post-update'>> hook in that it gets
Junio C Hamano323e52d2007-05-13 22:19:53354both old and new values of all the refs in addition to their
355names.
Junio C Hamano8638c922007-05-12 20:50:08356
Junio C Hamano323e52d2007-05-13 22:19:53357Both standard output and standard error output are forwarded to
Junio C Hamanob9d9d902018-05-23 07:07:42358`git send-pack` on the other end, so you can simply `echo` messages
Junio C Hamano323e52d2007-05-13 22:19:53359for the user.
Junio C Hamano8638c922007-05-12 20:50:08360
361The default 'post-receive' hook is empty, but there is
362a sample script `post-receive-email` provided in the `contrib/hooks`
Junio C Hamano076ffcc2013-02-06 05:13:21363directory in Git distribution, which implements sending commit
Junio C Hamano8638c922007-05-12 20:50:08364emails.
365
Junio C Hamanoe48a1132016-08-03 22:40:21366The number of push options given on the command line of
367`git push --push-option=...` can be read from the environment
368variable `GIT_PUSH_OPTION_COUNT`, and the options themselves are
369found in `GIT_PUSH_OPTION_0`, `GIT_PUSH_OPTION_1`,...
370If it is negotiated to not use the push options phase, the
371environment variables will not be set. If the client selects
372to use push options, but doesn't transmit any, the count variable
373will be set to zero, `GIT_PUSH_OPTION_COUNT=0`.
374
Junio C Hamano8638c922007-05-12 20:50:08375[[post-update]]
Junio C Hamano1a4e8412005-12-27 08:17:23376post-update
Junio C Hamanoc28068f2009-09-08 00:55:23377~~~~~~~~~~~
Junio C Hamano1a4e8412005-12-27 08:17:23378
Junio C Hamanob9d9d902018-05-23 07:07:42379This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
380`git push` and updates reference(s) in its repository.
Junio C Hamano818f7d62006-03-26 01:49:30381It executes on the remote repository once after all the refs have
382been updated.
383
384It takes a variable number of parameters, each of which is the
385name of ref that was actually updated.
Junio C Hamano1a4e8412005-12-27 08:17:23386
387This hook is meant primarily for notification, and cannot affect
Junio C Hamanob9d9d902018-05-23 07:07:42388the outcome of `git receive-pack`.
Junio C Hamano1a4e8412005-12-27 08:17:23389
Junio C Hamanod5784132006-09-20 21:29:27390The 'post-update' hook can tell what are the heads that were pushed,
Junio C Hamano818f7d62006-03-26 01:49:30391but it does not know what their original and updated values are,
Junio C Hamano323e52d2007-05-13 22:19:53392so it is a poor place to do log old..new. The
393<<post-receive,'post-receive'>> hook does get both original and
394updated values of the refs. You might consider it instead if you need
395them.
Junio C Hamano8638c922007-05-12 20:50:08396
Junio C Hamanod5784132006-09-20 21:29:27397When enabled, the default 'post-update' hook runs
Junio C Hamanob9d9d902018-05-23 07:07:42398`git update-server-info` to keep the information used by dumb
Junio C Hamano88bf5712017-09-10 08:39:23399transports (e.g., HTTP) up to date. If you are publishing
Junio C Hamano076ffcc2013-02-06 05:13:21400a Git repository that is accessible via HTTP, you should
Junio C Hamano818f7d62006-03-26 01:49:30401probably enable this hook.
Junio C Hamano1a4e8412005-12-27 08:17:23402
Junio C Hamano8638c922007-05-12 20:50:08403Both standard output and standard error output are forwarded to
Junio C Hamanob9d9d902018-05-23 07:07:42404`git send-pack` on the other end, so you can simply `echo` messages
Junio C Hamano323e52d2007-05-13 22:19:53405for the user.
Junio C Hamanoe3ddb5b2008-04-21 00:48:07406
Junio C Hamano6bb32e62015-02-17 22:11:26407push-to-checkout
408~~~~~~~~~~~~~~~~
409
Junio C Hamanob9d9d902018-05-23 07:07:42410This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
411`git push` and updates reference(s) in its repository, and when
Junio C Hamano6bb32e62015-02-17 22:11:26412the push tries to update the branch that is currently checked out
413and the `receive.denyCurrentBranch` configuration variable is set to
414`updateInstead`. Such a push by default is refused if the working
415tree and the index of the remote repository has any difference from
416the currently checked out commit; when both the working tree and the
417index match the current commit, they are updated to match the newly
418pushed tip of the branch. This hook is to be used to override the
419default behaviour.
420
421The hook receives the commit with which the tip of the current
422branch is going to be updated. It can exit with a non-zero status
423to refuse the push (when it does so, it must not modify the index or
424the working tree). Or it can make any necessary changes to the
425working tree and to the index to bring them to the desired state
426when the tip of the current branch is updated to the new commit, and
427exit with a zero status.
428
429For example, the hook can simply run `git read-tree -u -m HEAD "$1"`
Junio C Hamanob9d9d902018-05-23 07:07:42430in order to emulate `git fetch` that is run in the reverse direction
431with `git push`, as the two-tree form of `git read-tree -u -m` is
Junio C Hamanoc9f11c22019-07-10 02:54:04432essentially the same as `git switch` or `git checkout`
433that switches branches while
Junio C Hamano6bb32e62015-02-17 22:11:26434keeping the local changes in the working tree that do not interfere
435with the difference between the branches.
436
437
Junio C Hamanoe3ddb5b2008-04-21 00:48:07438pre-auto-gc
Junio C Hamanoc28068f2009-09-08 00:55:23439~~~~~~~~~~~
Junio C Hamanoe3ddb5b2008-04-21 00:48:07440
Junio C Hamanob9d9d902018-05-23 07:07:42441This hook is invoked by `git gc --auto` (see linkgit:git-gc[1]). It
442takes no parameter, and exiting with non-zero status from this script
443causes the `git gc --auto` to abort.
Junio C Hamano2fbcd212008-05-14 22:26:07444
Junio C Hamano31667362010-03-25 00:38:53445post-rewrite
446~~~~~~~~~~~~
447
Junio C Hamanob9d9d902018-05-23 07:07:42448This hook is invoked by commands that rewrite commits
449(linkgit:git-commit[1] when called with `--amend` and
Junio C Hamanoa8858312019-09-30 05:07:45450linkgit:git-rebase[1]; however, full-history (re)writing tools like
451linkgit:git-fast-import[1] or
452https://github.com/newren/git-filter-repo[git-filter-repo] typically
453do not call it!). Its first argument denotes the command it was
454invoked by: currently one of `amend` or `rebase`. Further
455command-dependent arguments may be passed in the future.
Junio C Hamano31667362010-03-25 00:38:53456
457The hook receives a list of the rewritten commits on stdin, in the
458format
459
460 <old-sha1> SP <new-sha1> [ SP <extra-info> ] LF
461
462The 'extra-info' is again command-dependent. If it is empty, the
463preceding SP is also omitted. Currently, no commands pass any
464'extra-info'.
465
466The hook always runs after the automatic note copying (see
Junio C Hamano96fdfa12016-03-21 20:52:39467"notes.rewrite.<command>" in linkgit:git-config[1]) has happened, and
Junio C Hamano31667362010-03-25 00:38:53468thus has access to these notes.
469
470The following command-specific comments apply:
471
472rebase::
473For the 'squash' and 'fixup' operation, all commits that were
474squashed are listed as being rewritten to the squashed commit.
475This means that there will be several lines sharing the same
476'new-sha1'.
477+
478The commits are guaranteed to be listed in the order that they were
479processed by rebase.
480
Junio C Hamanod88ba732017-05-30 04:14:20481sendemail-validate
482~~~~~~~~~~~~~~~~~~
483
Junio C Hamanob9d9d902018-05-23 07:07:42484This hook is invoked by linkgit:git-send-email[1]. It takes a single parameter,
Junio C Hamanod88ba732017-05-30 04:14:20485the name of the file that holds the e-mail to be sent. Exiting with a
Junio C Hamanob9d9d902018-05-23 07:07:42486non-zero status causes `git send-email` to abort before sending any
Junio C Hamanod88ba732017-05-30 04:14:20487e-mails.
488
Junio C Hamanod7105602017-11-21 05:32:50489fsmonitor-watchman
490~~~~~~~~~~~~~~~~~~
491
Junio C Hamanob9d9d902018-05-23 07:07:42492This hook is invoked when the configuration option `core.fsmonitor` is
493set to `.git/hooks/fsmonitor-watchman`. It takes two arguments, a version
Junio C Hamanod7105602017-11-21 05:32:50494(currently 1) and the time in elapsed nanoseconds since midnight,
495January 1, 1970.
496
497The hook should output to stdout the list of all files in the working
498directory that may have changed since the requested time. The logic
499should be inclusive so that it does not miss any potential changes.
500The paths should be relative to the root of the working directory
501and be separated by a single NUL.
502
503It is OK to include files which have not actually changed. All changes
504including newly-created and deleted files should be included. When
505files are renamed, both the old and the new name should be included.
506
507Git will limit what files it checks for changes as well as which
508directories are checked for untracked files based on the path names
509given.
510
511An optimized way to tell git "all files have changed" is to return
Junio C Hamanob9d9d902018-05-23 07:07:42512the filename `/`.
Junio C Hamanod7105602017-11-21 05:32:50513
514The exit status determines whether git will use the data from the
515hook to limit its search. On error, it will fall back to verifying
516all files and folders.
Junio C Hamano31667362010-03-25 00:38:53517
Junio C Hamanobfd91f42018-08-17 22:21:16518p4-pre-submit
519~~~~~~~~~~~~~
520
521This hook is invoked by `git-p4 submit`. It takes no parameters and nothing
522from standard input. Exiting with non-zero status from this script prevent
523`git-p4 submit` from launching. Run `git-p4 submit --help` for details.
524
Junio C Hamano2ba14712019-04-25 10:12:27525post-index-change
526~~~~~~~~~~~~~~~~~
527
528This hook is invoked when the index is written in read-cache.c
529do_write_locked_index.
530
531The first parameter passed to the hook is the indicator for the
532working directory being updated. "1" meaning working directory
533was updated or "0" when the working directory was not updated.
534
535The second parameter passed to the hook is the indicator for whether
536or not the index was updated and the skip-worktree bit could have
537changed. "1" meaning skip-worktree bits could have been updated
538and "0" meaning they were not.
539
540Only one parameter should be set to "1" when the hook runs. The hook
541running passing "1", "1" should not be possible.
542
Junio C Hamano2fbcd212008-05-14 22:26:07543GIT
544---
Junio C Hamanof7c042d2008-06-06 22:50:53545Part of the linkgit:git[1] suite