updated git doc
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-daemon.xml
blobeaecd9677ffa519e32c43b13a475599ac83860c6
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-daemon(1)">\r
5 <articleinfo>\r
6     <title>git-daemon(1)</title>\r
7 <indexterm>\r
8 <primary>git-daemon(1)</primary>\r
9 </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-daemon - A really simple server for git repositories</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git daemon</emphasis> [--verbose] [--syslog] [--export-all]\r
19              [--timeout=&lt;n&gt;] [--init-timeout=&lt;n&gt;] [--max-connections=&lt;n&gt;]\r
20              [--strict-paths] [--base-path=&lt;path&gt;] [--base-path-relaxed]\r
21              [--user-path | --user-path=&lt;path&gt;]\r
22              [--interpolated-path=&lt;pathtemplate&gt;]\r
23              [--reuseaddr] [--detach] [--pid-file=&lt;file&gt;]\r
24              [--enable=&lt;service&gt;] [--disable=&lt;service&gt;]\r
25              [--allow-override=&lt;service&gt;] [--forbid-override=&lt;service&gt;]\r
26              [--inetd | [--listen=&lt;host_or_ipaddr&gt;] [--port=&lt;n&gt;] [--user=&lt;user&gt; [--group=&lt;group&gt;]]\r
27              [&lt;directory&gt;&#8230;]</literallayout>\r
28 </blockquote>\r
29 </simplesect>\r
30 <simplesect id="_description">\r
31 <title>DESCRIPTION</title>\r
32 <simpara>A really simple TCP git daemon that normally listens on port "DEFAULT_GIT_PORT"\r
33 aka 9418.  It waits for a connection asking for a service, and will serve\r
34 that service if it is enabled.</simpara>\r
35 <simpara>It verifies that the directory has the magic file "git-daemon-export-ok", and\r
36 it will refuse to export any git directory that hasn't explicitly been marked\r
37 for export this way (unless the <emphasis>--export-all</emphasis> parameter is specified). If you\r
38 pass some directory paths as <emphasis>git daemon</emphasis> arguments, you can further restrict\r
39 the offers to a whitelist comprising of those.</simpara>\r
40 <simpara>By default, only <emphasis>upload-pack</emphasis> service is enabled, which serves\r
41 <emphasis>git fetch-pack</emphasis> and <emphasis>git ls-remote</emphasis> clients, which are invoked\r
42 from <emphasis>git fetch</emphasis>, <emphasis>git pull</emphasis>, and <emphasis>git clone</emphasis>.</simpara>\r
43 <simpara>This is ideally suited for read-only updates, i.e., pulling from\r
44 git repositories.</simpara>\r
45 <simpara>An <emphasis>upload-archive</emphasis> also exists to serve <emphasis>git archive</emphasis>.</simpara>\r
46 </simplesect>\r
47 <simplesect id="_options">\r
48 <title>OPTIONS</title>\r
49 <variablelist>\r
50 <varlistentry>\r
51 <term>\r
52 --strict-paths\r
53 </term>\r
54 <listitem>\r
55 <simpara>\r
56         Match paths exactly (i.e. don't allow "/foo/repo" when the real path is\r
57         "/foo/repo.git" or "/foo/repo/.git") and don't do user-relative paths.\r
58         <emphasis>git daemon</emphasis> will refuse to start when this option is enabled and no\r
59         whitelist is specified.\r
60 </simpara>\r
61 </listitem>\r
62 </varlistentry>\r
63 <varlistentry>\r
64 <term>\r
65 --base-path=&lt;path&gt;\r
66 </term>\r
67 <listitem>\r
68 <simpara>\r
69         Remap all the path requests as relative to the given path.\r
70         This is sort of "GIT root" - if you run <emphasis>git daemon</emphasis> with\r
71         <emphasis>--base-path=/srv/git</emphasis> on example.com, then if you later try to pull\r
72         <emphasis>git://example.com/hello.git</emphasis>, <emphasis>git daemon</emphasis> will interpret the path\r
73         as <emphasis>/srv/git/hello.git</emphasis>.\r
74 </simpara>\r
75 </listitem>\r
76 </varlistentry>\r
77 <varlistentry>\r
78 <term>\r
79 --base-path-relaxed\r
80 </term>\r
81 <listitem>\r
82 <simpara>\r
83         If --base-path is enabled and repo lookup fails, with this option\r
84         <emphasis>git daemon</emphasis> will attempt to lookup without prefixing the base path.\r
85         This is useful for switching to --base-path usage, while still\r
86         allowing the old paths.\r
87 </simpara>\r
88 </listitem>\r
89 </varlistentry>\r
90 <varlistentry>\r
91 <term>\r
92 --interpolated-path=&lt;pathtemplate&gt;\r
93 </term>\r
94 <listitem>\r
95 <simpara>\r
96         To support virtual hosting, an interpolated path template can be\r
97         used to dynamically construct alternate paths.  The template\r
98         supports %H for the target hostname as supplied by the client but\r
99         converted to all lowercase, %CH for the canonical hostname,\r
100         %IP for the server's IP address, %P for the port number,\r
101         and %D for the absolute path of the named repository.\r
102         After interpolation, the path is validated against the directory\r
103         whitelist.\r
104 </simpara>\r
105 </listitem>\r
106 </varlistentry>\r
107 <varlistentry>\r
108 <term>\r
109 --export-all\r
110 </term>\r
111 <listitem>\r
112 <simpara>\r
113         Allow pulling from all directories that look like GIT repositories\r
114         (have the <emphasis>objects</emphasis> and <emphasis>refs</emphasis> subdirectories), even if they\r
115         do not have the <emphasis>git-daemon-export-ok</emphasis> file.\r
116 </simpara>\r
117 </listitem>\r
118 </varlistentry>\r
119 <varlistentry>\r
120 <term>\r
121 --inetd\r
122 </term>\r
123 <listitem>\r
124 <simpara>\r
125         Have the server run as an inetd service. Implies --syslog.\r
126         Incompatible with --detach, --port, --listen, --user and --group\r
127         options.\r
128 </simpara>\r
129 </listitem>\r
130 </varlistentry>\r
131 <varlistentry>\r
132 <term>\r
133 --listen=&lt;host_or_ipaddr&gt;\r
134 </term>\r
135 <listitem>\r
136 <simpara>\r
137         Listen on a specific IP address or hostname.  IP addresses can\r
138         be either an IPv4 address or an IPv6 address if supported.  If IPv6\r
139         is not supported, then --listen=hostname is also not supported and\r
140         --listen must be given an IPv4 address.\r
141         Can be given more than once.\r
142         Incompatible with <emphasis>--inetd</emphasis> option.\r
143 </simpara>\r
144 </listitem>\r
145 </varlistentry>\r
146 <varlistentry>\r
147 <term>\r
148 --port=&lt;n&gt;\r
149 </term>\r
150 <listitem>\r
151 <simpara>\r
152         Listen on an alternative port.  Incompatible with <emphasis>--inetd</emphasis> option.\r
153 </simpara>\r
154 </listitem>\r
155 </varlistentry>\r
156 <varlistentry>\r
157 <term>\r
158 --init-timeout=&lt;n&gt;\r
159 </term>\r
160 <listitem>\r
161 <simpara>\r
162         Timeout (in seconds) between the moment the connection is established\r
163         and the client request is received (typically a rather low value, since\r
164         that should be basically immediate).\r
165 </simpara>\r
166 </listitem>\r
167 </varlistentry>\r
168 <varlistentry>\r
169 <term>\r
170 --timeout=&lt;n&gt;\r
171 </term>\r
172 <listitem>\r
173 <simpara>\r
174         Timeout (in seconds) for specific client sub-requests. This includes\r
175         the time it takes for the server to process the sub-request and the\r
176         time spent waiting for the next client's request.\r
177 </simpara>\r
178 </listitem>\r
179 </varlistentry>\r
180 <varlistentry>\r
181 <term>\r
182 --max-connections=&lt;n&gt;\r
183 </term>\r
184 <listitem>\r
185 <simpara>\r
186         Maximum number of concurrent clients, defaults to 32.  Set it to\r
187         zero for no limit.\r
188 </simpara>\r
189 </listitem>\r
190 </varlistentry>\r
191 <varlistentry>\r
192 <term>\r
193 --syslog\r
194 </term>\r
195 <listitem>\r
196 <simpara>\r
197         Log to syslog instead of stderr. Note that this option does not imply\r
198         --verbose, thus by default only error conditions will be logged.\r
199 </simpara>\r
200 </listitem>\r
201 </varlistentry>\r
202 <varlistentry>\r
203 <term>\r
204 --user-path\r
205 </term>\r
206 <term>\r
207 --user-path=&lt;path&gt;\r
208 </term>\r
209 <listitem>\r
210 <simpara>\r
211         Allow &#126;user notation to be used in requests.  When\r
212         specified with no parameter, requests to\r
213         git://host/&#126;alice/foo is taken as a request to access\r
214         <emphasis>foo</emphasis> repository in the home directory of user <emphasis>alice</emphasis>.\r
215         If <emphasis>--user-path=path</emphasis> is specified, the same request is\r
216         taken as a request to access <emphasis>path/foo</emphasis> repository in\r
217         the home directory of user <emphasis>alice</emphasis>.\r
218 </simpara>\r
219 </listitem>\r
220 </varlistentry>\r
221 <varlistentry>\r
222 <term>\r
223 --verbose\r
224 </term>\r
225 <listitem>\r
226 <simpara>\r
227         Log details about the incoming connections and requested files.\r
228 </simpara>\r
229 </listitem>\r
230 </varlistentry>\r
231 <varlistentry>\r
232 <term>\r
233 --reuseaddr\r
234 </term>\r
235 <listitem>\r
236 <simpara>\r
237         Use SO_REUSEADDR when binding the listening socket.\r
238         This allows the server to restart without waiting for\r
239         old connections to time out.\r
240 </simpara>\r
241 </listitem>\r
242 </varlistentry>\r
243 <varlistentry>\r
244 <term>\r
245 --detach\r
246 </term>\r
247 <listitem>\r
248 <simpara>\r
249         Detach from the shell. Implies --syslog.\r
250 </simpara>\r
251 </listitem>\r
252 </varlistentry>\r
253 <varlistentry>\r
254 <term>\r
255 --pid-file=&lt;file&gt;\r
256 </term>\r
257 <listitem>\r
258 <simpara>\r
259         Save the process id in <emphasis>file</emphasis>.  Ignored when the daemon\r
260         is run under <emphasis>--inetd</emphasis>.\r
261 </simpara>\r
262 </listitem>\r
263 </varlistentry>\r
264 <varlistentry>\r
265 <term>\r
266 --user=&lt;user&gt;\r
267 </term>\r
268 <term>\r
269 --group=&lt;group&gt;\r
270 </term>\r
271 <listitem>\r
272 <simpara>\r
273         Change daemon's uid and gid before entering the service loop.\r
274         When only <emphasis>--user</emphasis> is given without <emphasis>--group</emphasis>, the\r
275         primary group ID for the user is used.  The values of\r
276         the option are given to <emphasis>getpwnam(3)</emphasis> and <emphasis>getgrnam(3)</emphasis>\r
277         and numeric IDs are not supported.\r
278 </simpara>\r
279 <simpara>Giving these options is an error when used with <emphasis>--inetd</emphasis>; use\r
280 the facility of inet daemon to achieve the same before spawning\r
281 <emphasis>git daemon</emphasis> if needed.</simpara>\r
282 </listitem>\r
283 </varlistentry>\r
284 <varlistentry>\r
285 <term>\r
286 --enable=&lt;service&gt;\r
287 </term>\r
288 <term>\r
289 --disable=&lt;service&gt;\r
290 </term>\r
291 <listitem>\r
292 <simpara>\r
293         Enable/disable the service site-wide per default.  Note\r
294         that a service disabled site-wide can still be enabled\r
295         per repository if it is marked overridable and the\r
296         repository enables the service with a configuration\r
297         item.\r
298 </simpara>\r
299 </listitem>\r
300 </varlistentry>\r
301 <varlistentry>\r
302 <term>\r
303 --allow-override=&lt;service&gt;\r
304 </term>\r
305 <term>\r
306 --forbid-override=&lt;service&gt;\r
307 </term>\r
308 <listitem>\r
309 <simpara>\r
310         Allow/forbid overriding the site-wide default with per\r
311         repository configuration.  By default, all the services\r
312         are overridable.\r
313 </simpara>\r
314 </listitem>\r
315 </varlistentry>\r
316 <varlistentry>\r
317 <term>\r
318 --informative-errors\r
319 </term>\r
320 <term>\r
321 --no-informative-errors\r
322 </term>\r
323 <listitem>\r
324 <simpara>\r
325         When informative errors are turned on, git-daemon will report\r
326         more verbose errors to the client, differentiating conditions\r
327         like "no such repository" from "repository not exported". This\r
328         is more convenient for clients, but may leak information about\r
329         the existence of unexported repositories.  When informative\r
330         errors are not enabled, all errors report "access denied" to the\r
331         client. The default is --no-informative-errors.\r
332 </simpara>\r
333 </listitem>\r
334 </varlistentry>\r
335 <varlistentry>\r
336 <term>\r
337 &lt;directory&gt;\r
338 </term>\r
339 <listitem>\r
340 <simpara>\r
341         A directory to add to the whitelist of allowed directories. Unless\r
342         --strict-paths is specified this will also include subdirectories\r
343         of each named directory.\r
344 </simpara>\r
345 </listitem>\r
346 </varlistentry>\r
347 </variablelist>\r
348 </simplesect>\r
349 <simplesect id="_services">\r
350 <title>SERVICES</title>\r
351 <simpara>These services can be globally enabled/disabled using the\r
352 command line options of this command.  If a finer-grained\r
353 control is desired (e.g. to allow <emphasis>git archive</emphasis> to be run\r
354 against only in a few selected repositories the daemon serves),\r
355 the per-repository configuration file can be used to enable or\r
356 disable them.</simpara>\r
357 <variablelist>\r
358 <varlistentry>\r
359 <term>\r
360 upload-pack\r
361 </term>\r
362 <listitem>\r
363 <simpara>\r
364         This serves <emphasis>git fetch-pack</emphasis> and <emphasis>git ls-remote</emphasis>\r
365         clients.  It is enabled by default, but a repository can\r
366         disable it by setting <emphasis>daemon.uploadpack</emphasis> configuration\r
367         item to <emphasis>false</emphasis>.\r
368 </simpara>\r
369 </listitem>\r
370 </varlistentry>\r
371 <varlistentry>\r
372 <term>\r
373 upload-archive\r
374 </term>\r
375 <listitem>\r
376 <simpara>\r
377         This serves <emphasis>git archive --remote</emphasis>.  It is disabled by\r
378         default, but a repository can enable it by setting\r
379         <emphasis>daemon.uploadarch</emphasis> configuration item to <emphasis>true</emphasis>.\r
380 </simpara>\r
381 </listitem>\r
382 </varlistentry>\r
383 <varlistentry>\r
384 <term>\r
385 receive-pack\r
386 </term>\r
387 <listitem>\r
388 <simpara>\r
389         This serves <emphasis>git send-pack</emphasis> clients, allowing anonymous\r
390         push.  It is disabled by default, as there is <emphasis>no</emphasis>\r
391         authentication in the protocol (in other words, anybody\r
392         can push anything into the repository, including removal\r
393         of refs).  This is solely meant for a closed LAN setting\r
394         where everybody is friendly.  This service can be\r
395         enabled by <emphasis>daemon.receivepack</emphasis> configuration item to\r
396         <emphasis>true</emphasis>.\r
397 </simpara>\r
398 </listitem>\r
399 </varlistentry>\r
400 </variablelist>\r
401 </simplesect>\r
402 <simplesect id="_examples">\r
403 <title>EXAMPLES</title>\r
404 <variablelist>\r
405 <varlistentry>\r
406 <term>\r
407 We assume the following in /etc/services\r
408 </term>\r
409 <listitem>\r
410 <screen>$ grep 9418 /etc/services\r
411 git             9418/tcp                # Git Version Control System</screen>\r
412 </listitem>\r
413 </varlistentry>\r
414 <varlistentry>\r
415 <term>\r
416 <emphasis>git daemon</emphasis> as inetd server\r
417 </term>\r
418 <listitem>\r
419 <simpara>\r
420         To set up <emphasis>git daemon</emphasis> as an inetd service that handles any\r
421         repository under the whitelisted set of directories, /pub/foo\r
422         and /pub/bar, place an entry like the following into\r
423         /etc/inetd all on one line:\r
424 </simpara>\r
425 <screen>        git stream tcp nowait nobody  /usr/bin/git\r
426                 git daemon --inetd --verbose --export-all\r
427                 /pub/foo /pub/bar</screen>\r
428 </listitem>\r
429 </varlistentry>\r
430 <varlistentry>\r
431 <term>\r
432 <emphasis>git daemon</emphasis> as inetd server for virtual hosts\r
433 </term>\r
434 <listitem>\r
435 <simpara>\r
436         To set up <emphasis>git daemon</emphasis> as an inetd service that handles\r
437         repositories for different virtual hosts, <emphasis>www.example.com</emphasis>\r
438         and <emphasis>www.example.org</emphasis>, place an entry like the following into\r
439         <emphasis>/etc/inetd</emphasis> all on one line:\r
440 </simpara>\r
441 <screen>        git stream tcp nowait nobody /usr/bin/git\r
442                 git daemon --inetd --verbose --export-all\r
443                 --interpolated-path=/pub/%H%D\r
444                 /pub/www.example.org/software\r
445                 /pub/www.example.com/software\r
446                 /software</screen>\r
447 <simpara>In this example, the root-level directory <emphasis>/pub</emphasis> will contain\r
448 a subdirectory for each virtual host name supported.\r
449 Further, both hosts advertise repositories simply as\r
450 <emphasis>git://www.example.com/software/repo.git</emphasis>.  For pre-1.4.0\r
451 clients, a symlink from <emphasis>/software</emphasis> into the appropriate\r
452 default repository could be made as well.</simpara>\r
453 </listitem>\r
454 </varlistentry>\r
455 <varlistentry>\r
456 <term>\r
457 <emphasis>git daemon</emphasis> as regular daemon for virtual hosts\r
458 </term>\r
459 <listitem>\r
460 <simpara>\r
461         To set up <emphasis>git daemon</emphasis> as a regular, non-inetd service that\r
462         handles repositories for multiple virtual hosts based on\r
463         their IP addresses, start the daemon like this:\r
464 </simpara>\r
465 <screen>        git daemon --verbose --export-all\r
466                 --interpolated-path=/pub/%IP/%D\r
467                 /pub/192.168.1.200/software\r
468                 /pub/10.10.220.23/software</screen>\r
469 <simpara>In this example, the root-level directory <emphasis>/pub</emphasis> will contain\r
470 a subdirectory for each virtual host IP address supported.\r
471 Repositories can still be accessed by hostname though, assuming\r
472 they correspond to these IP addresses.</simpara>\r
473 </listitem>\r
474 </varlistentry>\r
475 <varlistentry>\r
476 <term>\r
477 selectively enable/disable services per repository\r
478 </term>\r
479 <listitem>\r
480 <simpara>\r
481         To enable <emphasis>git archive --remote</emphasis> and disable <emphasis>git fetch</emphasis> against\r
482         a repository, have the following in the configuration file in the\r
483         repository (that is the file <emphasis>config</emphasis> next to <emphasis>HEAD</emphasis>, <emphasis>refs</emphasis> and\r
484         <emphasis>objects</emphasis>).\r
485 </simpara>\r
486 <screen>        [daemon]\r
487                 uploadpack = false\r
488                 uploadarch = true</screen>\r
489 </listitem>\r
490 </varlistentry>\r
491 </variablelist>\r
492 </simplesect>\r
493 <simplesect id="_environment">\r
494 <title>ENVIRONMENT</title>\r
495 <simpara><emphasis>git daemon</emphasis> will set REMOTE_ADDR to the IP address of the client\r
496 that connected to it, if the IP address is available. REMOTE_ADDR will\r
497 be available in the environment of hooks called when\r
498 services are performed.</simpara>\r
499 </simplesect>\r
500 <simplesect id="_git">\r
501 <title>GIT</title>\r
502 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
503 </simplesect>\r
504 </article>\r