]>
Commit | Line | Data |
---|---|---|
6d35cc76 JH |
1 | Hooks used by GIT |
2 | ================= | |
3 | v0.99.6, Sep 2005 | |
4 | ||
5 | Hooks are little scripts you can place in `$GIT_DIR/hooks` | |
6 | directory to trigger action at certain points. When | |
7 | `git-init-db` is run, a handful example hooks are copied in the | |
8 | `hooks` directory of the new repository, but by default they are | |
9 | all disabled. To enable a hook, make it executable with `chmod | |
10 | +x`. | |
11 | ||
12 | This document describes the currently defined hooks. | |
13 | ||
14 | applypatch-msg | |
15 | -------------- | |
16 | ||
17 | This hook is invoked by `git-applypatch` script, which is | |
18 | typically invoked by `git-applymbox`. It takes a single | |
19 | parameter, the name of the file that holds the proposed commit | |
20 | log message. Exiting with non-zero status causes the | |
21 | 'git-applypatch' to abort before applying the patch. | |
22 | ||
23 | The hook is allowed to edit the message file in place, and can | |
24 | be used to normalize the message into some project standard | |
25 | format (if the project has one). It can also be used to refuse | |
26 | the commit after inspecting the message file. | |
27 | ||
28 | The default applypatch-msg hook, when enabled, runs the | |
29 | commit-msg hook, if the latter is enabled. | |
30 | ||
31 | pre-applypatch | |
32 | -------------- | |
33 | ||
34 | This hook is invoked by `git-applypatch` script, which is | |
35 | typically invoked by `git-applymbox`. It takes no parameter, | |
36 | and is invoked after the patch is applied, but before a commit | |
37 | is made. Exiting with non-zero status causes the working tree | |
38 | after application of the patch not committed. | |
39 | ||
40 | It can be used to inspect the current working tree and refuse to | |
41 | make a commit if it does not pass certain test. | |
42 | ||
43 | The default pre-applypatch hook, when enabled, runs the | |
44 | pre-commit hook, if the latter is enabled. | |
45 | ||
46 | post-applypatch | |
47 | --------------- | |
48 | ||
49 | This hook is invoked by `git-applypatch` script, which is | |
50 | typically invoked by `git-applymbox`. It takes no parameter, | |
51 | and is invoked after the patch is applied and a commit is made. | |
52 | ||
53 | This hook is meant primarily for notification, and cannot affect | |
54 | the outcome of `git-applypatch`. | |
55 | ||
56 | pre-commit | |
57 | ---------- | |
58 | ||
215a7ad1 | 59 | This hook is invoked by `git-commit`, and can be bypassed |
6d35cc76 JH |
60 | with `--no-verify` option. It takes no parameter, and is |
61 | invoked before obtaining the proposed commit log message and | |
62 | making a commit. Exiting with non-zero status from this script | |
215a7ad1 | 63 | causes the `git-commit` to abort. |
6d35cc76 JH |
64 | |
65 | The default pre-commit hook, when enabled, catches introduction | |
66 | of lines with trailing whitespaces and aborts the commit when | |
67 | a such line is found. | |
68 | ||
69 | commit-msg | |
70 | ---------- | |
71 | ||
215a7ad1 | 72 | This hook is invoked by `git-commit`, and can be bypassed |
6d35cc76 JH |
73 | with `--no-verify` option. It takes a single parameter, the |
74 | name of the file that holds the proposed commit log message. | |
215a7ad1 | 75 | Exiting with non-zero status causes the `git-commit` to |
6d35cc76 JH |
76 | abort. |
77 | ||
78 | The hook is allowed to edit the message file in place, and can | |
79 | be used to normalize the message into some project standard | |
80 | format (if the project has one). It can also be used to refuse | |
81 | the commit after inspecting the message file. | |
82 | ||
83 | The default commit-msg hook, when enabled, detects duplicate | |
84 | Signed-off-by: lines, and aborts the commit when one is found. | |
85 | ||
86 | post-commit | |
87 | ----------- | |
88 | ||
215a7ad1 | 89 | This hook is invoked by `git-commit`. It takes no |
6d35cc76 JH |
90 | parameter, and is invoked after a commit is made. |
91 | ||
92 | This hook is meant primarily for notification, and cannot affect | |
215a7ad1 | 93 | the outcome of `git-commit`. |
6d35cc76 JH |
94 | |
95 | The default post-commit hook, when enabled, demonstrates how to | |
96 | send out a commit notification e-mail. | |
97 | ||
98 | update | |
99 | ------ | |
100 | ||
101 | This hook is invoked by `git-receive-pack`, which is invoked | |
102 | when a `git push` is done against the repository. It takes | |
103 | three parameters, name of the ref being updated, old object name | |
104 | stored in the ref, and the new objectname to be stored in the | |
105 | ref. Exiting with non-zero status from this hook prevents | |
106 | `git-receive-pack` from updating the ref. | |
107 | ||
108 | This can be used to prevent 'forced' update on certain refs by | |
109 | making sure that the object name is a commit object that is a | |
110 | descendant of the commit object named by the old object name. | |
111 | Another use suggested on the mailing list is to use this hook to | |
112 | implement access control which is finer grained than the one | |
113 | based on filesystem group. | |
114 | ||
115 | post-update | |
116 | ----------- | |
117 | ||
118 | This hook is invoked by `git-receive-pack`, which is invoked | |
119 | when a `git push` is done against the repository. It takes | |
120 | variable number of parameters; each of which is the name of ref | |
121 | that was actually updated. | |
122 | ||
123 | This hook is meant primarily for notification, and cannot affect | |
124 | the outcome of `git-receive-pack`. | |
125 | ||
126 | The default post-update hook, when enabled, runs | |
127 | `git-update-server-info` to keep the information used by dumb | |
128 | transport up-to-date. |