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.
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 receive-pack runs, but to the user who is sitting at the send-pack end,
23 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
42 sha1-old SP sha1-new SP refname LF
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
63 $GIT_DIR/hooks/update refname sha1-old sha1-new
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 invoke once with no parameters. The
83 standard input of the hook will be one line for each successfully
84 updated ref:
85
86
87 sha1-old SP sha1-new SP refname LF
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
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 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 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 called with the list of refs that have been updated.
128 This can be used to implement any repository wide cleanup tasks.
129
130 The exit code from this hook invocation is ignored; the only thing left
131 for git-receive-pack to do at that point is to exit itself anyway.
132
133 This hook can be used, for example, to run "git-update-server-info" if
134 the repository is packed and is served via a dumb transport.
135
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>
145
147 Documentation by Junio C Hamano.
148
150 Part of the git(7) suite
151
152
153
154
155Git 1.5.3.3 10/09/2007 GIT-RECEIVE-PACK(1)