]>
Commit | Line | Data |
---|---|---|
2a245013 JH |
1 | git-receive-pack(1) |
2 | =================== | |
3 | v0.1, July 2005 | |
4 | ||
5 | NAME | |
6 | ---- | |
7 | git-receive-pack - Receive what is pushed into it | |
8 | ||
9 | ||
10 | SYNOPSIS | |
11 | -------- | |
12 | 'git-receive-pack' <directory> | |
13 | ||
14 | DESCRIPTION | |
15 | ----------- | |
16 | Invoked by 'git-send-pack' and updates the repository with the | |
17 | information fed from the remote end. | |
18 | ||
19 | This command is usually not invoked directly by the end user. | |
20 | The UI for the protocol is on the 'git-send-pack' side, and the | |
21 | program pair is meant to be used to push updates to remote | |
22 | repository. For pull operations, see 'git-fetch-pack' and | |
23 | 'git-clone-pack'. | |
24 | ||
b1bf95bb JW |
25 | The command allows for creation and fast forwarding of sha1 refs |
26 | (heads/tags) on the remote end (strictly speaking, it is the | |
27 | local end receive-pack runs, but to the user who is sitting at | |
28 | the send-pack end, it is updating the remote. Confused?) | |
29 | ||
30 | Before each ref is updated, if $GIT_DIR/hooks/update file exists | |
31 | and executable, it is called with three parameters: | |
32 | ||
33 | $GIT_DIR/hooks/update refname sha1-old sha1-new | |
34 | ||
35 | The refname parameter is relative to $GIT_DIR; e.g. for the | |
36 | master head this is "refs/heads/master". Two sha1 are the | |
37 | object names for the refname before and after the update. Note | |
38 | that the hook is called before the refname is updated, so either | |
39 | sha1-old is 0{40} (meaning there is no such ref yet), or it | |
40 | should match what is recorded in refname. | |
41 | ||
42 | The hook should exit with non-zero status if it wants to | |
43 | disallow updating the named ref. Otherwise it should exit with | |
44 | zero. | |
45 | ||
b1bf95bb JW |
46 | Using this hook, it is easy to generate mails on updates to |
47 | the local repository. This example script sends a mail with | |
48 | the commits pushed to the repository: | |
49 | ||
50 | #!/bin/sh | |
19614330 JH |
51 | # mail out commit update information. |
52 | if expr "$2" : '0*$' >/dev/null | |
53 | then | |
54 | echo "Created a new ref, with the following commits:" | |
b1bf95bb | 55 | git-rev-list --pretty "$2" |
19614330 JH |
56 | else |
57 | echo "New commits:" | |
b1bf95bb | 58 | git-rev-list --pretty "$3" "^$2" |
19614330 JH |
59 | fi | |
60 | mail -s "Changes to ref $1" commit-list@mydomain | |
b1bf95bb | 61 | exit 0 |
2a245013 | 62 | |
19614330 JH |
63 | Another hook $GIT_DIR/hooks/post-update, if exists and |
64 | executable, is called with the list of refs that have been | |
65 | updated. This can be used to implement repository wide cleanup | |
66 | task if needed. The exit code from this hook invocation is | |
67 | ignored; the only thing left for git-receive-pack to do at that | |
68 | point is to exit itself anyway. This hook can be used, for | |
69 | example, to run "git-update-server-info" if the repository is | |
70 | packed and is served via a dumb transport. | |
71 | ||
72 | #!/bin/sh | |
73 | exec git-update-server-info | |
74 | ||
2a245013 JH |
75 | OPTIONS |
76 | ------- | |
77 | <directory>:: | |
78 | The repository to sync into. | |
79 | ||
6d35cc76 JH |
80 | |
81 | SEE ALSO | |
82 | -------- | |
83 | link:git-send-pack.html[git-send-pack] | |
84 | ||
85 | ||
2a245013 JH |
86 | Author |
87 | ------ | |
88 | Written by Linus Torvalds <torvalds@osdl.org> | |
89 | ||
90 | Documentation | |
91 | -------------- | |
92 | Documentation by Junio C Hamano. | |
93 | ||
94 | GIT | |
95 | --- | |
96 | Part of the link:git.html[git] suite |