OSDN Git Service

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