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