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