1GIT-RECEIVE-PACK(1) Git Manual GIT-RECEIVE-PACK(1)
2
3
4
6 git-receive-pack - Receive what is pushed into the repository
7
9 git-receive-pack <directory>
10
11
13 Invoked by git send-pack and updates the repository with the
14 information fed from the remote end.
15
16 This command is usually not invoked directly by the end user. The UI
17 for the protocol is on the git send-pack side, and the program pair is
18 meant to be used to push updates to remote repository. For pull
19 operations, see git-fetch-pack(1).
20
21 The command allows for creation and fast-forwarding of sha1 refs
22 (heads/tags) on the remote end (strictly speaking, it is the local end
23 git-receive-pack runs, but to the user who is sitting at the send-pack
24 end, it is updating the remote. Confused?)
25
26 There are other real-world examples of using update and post-update
27 hooks found in the Documentation/howto directory.
28
29 git-receive-pack honours the receive.denyNonFastForwards config option,
30 which tells it if updates to a ref should be denied if they are not
31 fast-forwards.
32
34 <directory>
35 The repository to sync into.
36
38 Before any ref is updated, if $GIT_DIR/hooks/pre-receive file exists
39 and is executable, it will be invoked once with no parameters. The
40 standard input of the hook will be one line per ref to be updated:
41
42 sha1-old SP sha1-new SP refname LF
43
44 The refname value is relative to $GIT_DIR; e.g. for the master head
45 this is "refs/heads/master". The two sha1 values before each refname
46 are the object names for the refname before and after the update. Refs
47 to be created will have sha1-old equal to 0{40}, while refs to be
48 deleted will have sha1-new equal to 0{40}, otherwise sha1-old and
49 sha1-new should be valid objects in the repository.
50
51 This hook is called before any refname is updated and before any
52 fast-forward checks are performed.
53
54 If the pre-receive hook exits with a non-zero exit status no updates
55 will be performed, and the update, post-receive and post-update hooks
56 will not be invoked either. This can be useful to quickly bail out if
57 the update is not to be supported.
58
60 Before each ref is updated, if $GIT_DIR/hooks/update file exists and is
61 executable, it is invoked once per ref, with three parameters:
62
63 $GIT_DIR/hooks/update refname sha1-old sha1-new
64
65 The refname parameter is relative to $GIT_DIR; e.g. for the master head
66 this is "refs/heads/master". The two sha1 arguments are the object
67 names for the refname before and after the update. Note that the hook
68 is called before the refname is updated, so either sha1-old is 0{40}
69 (meaning there is no such ref yet), or it should match what is recorded
70 in refname.
71
72 The hook should exit with non-zero status if it wants to disallow
73 updating the named ref. Otherwise it should exit with zero.
74
75 Successful execution (a zero exit status) of this hook does not ensure
76 the ref will actually be updated, it is only a prerequisite. As such it
77 is not a good idea to send notices (e.g. email) from this hook.
78 Consider using the post-receive hook instead.
79
81 After all refs were updated (or attempted to be updated), if any ref
82 update was successful, and if $GIT_DIR/hooks/post-receive file exists
83 and is executable, it will be invoked once with no parameters. The
84 standard input of the hook will be one line for each successfully
85 updated ref:
86
87 sha1-old SP sha1-new SP refname LF
88
89 The refname value is relative to $GIT_DIR; e.g. for the master head
90 this is "refs/heads/master". The two sha1 values before each refname
91 are the object names for the refname before and after the update. Refs
92 that were created will have sha1-old equal to 0{40}, while refs that
93 were deleted will have sha1-new equal to 0{40}, otherwise sha1-old and
94 sha1-new should be valid objects in the repository.
95
96 Using this hook, it is easy to generate mails describing the updates to
97 the repository. This example script sends one mail message per ref
98 listing the commits pushed to the repository:
99
100 #!/bin/sh
101 # mail out commit update information.
102 while read oval nval ref
103 do
104 if expr "$oval" : '0*$' >/dev/null
105 then
106 echo "Created a new ref, with the following commits:"
107 git rev-list --pretty "$nval"
108 else
109 echo "New commits:"
110 git rev-list --pretty "$nval" "^$oval"
111 fi |
112 mail -s "Changes to ref $ref" commit-list@mydomain
113 done
114 exit 0
115
116 The exit code from this hook invocation is ignored, however a non-zero
117 exit code will generate an error message.
118
119 Note that it is possible for refname to not have sha1-new when this
120 hook runs. This can easily occur if another user modifies the ref after
121 it was updated by git-receive-pack, but before the hook was able to
122 evaluate it. It is recommended that hooks rely on sha1-new rather than
123 the current value of refname.
124
126 After all other processing, if at least one ref was updated, and if
127 $GIT_DIR/hooks/post-update file exists and is executable, then
128 post-update will be called with the list of refs that have been
129 updated. This can be used to implement any repository wide cleanup
130 tasks.
131
132 The exit code from this hook invocation is ignored; the only thing left
133 for git-receive-pack to do at that point is to exit itself anyway.
134
135 This hook can be used, for example, to run git update-server-info if
136 the repository is packed and is served via a dumb transport.
137
138 #!/bin/sh
139 exec git update-server-info
140
142 git-send-pack(1), gitnamespaces(7)
143
145 Part of the git(1) suite
146
147
148
149Git 1.8.3.1 11/19/2018 GIT-RECEIVE-PACK(1)