]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-daemon.txt
Merge branch 'js/t3404-typofix' into maint
[thirdparty/git.git] / Documentation / git-daemon.txt
CommitLineData
7fc9d69f
JH
1git-daemon(1)
2=============
3
4NAME
5----
2de9b711 6git-daemon - A really simple server for Git repositories
7fc9d69f
JH
7
8SYNOPSIS
9--------
353ce815 10[verse]
b1889c36 11'git daemon' [--verbose] [--syslog] [--export-all]
62b4698e
ŠN
12 [--timeout=<n>] [--init-timeout=<n>] [--max-connections=<n>]
13 [--strict-paths] [--base-path=<path>] [--base-path-relaxed]
14 [--user-path | --user-path=<path>]
15 [--interpolated-path=<pathtemplate>]
16 [--reuseaddr] [--detach] [--pid-file=<file>]
17 [--enable=<service>] [--disable=<service>]
18 [--allow-override=<service>] [--forbid-override=<service>]
0460ed2c
FC
19 [--access-hook=<path>] [--[no-]informative-errors]
20 [--inetd |
21 [--listen=<host_or_ipaddr>] [--port=<n>]
22 [--user=<user> [--group=<group>]]]
0c591cac 23 [--log-destination=(stderr|syslog|none)]
62b4698e 24 [<directory>...]
7fc9d69f
JH
25
26DESCRIPTION
27-----------
2de9b711 28A really simple TCP Git daemon that normally listens on port "DEFAULT_GIT_PORT"
355f5412
JH
29aka 9418. It waits for a connection asking for a service, and will serve
30that service if it is enabled.
7fc9d69f 31
62cd033d 32It verifies that the directory has the magic file "git-daemon-export-ok", and
2de9b711 33it will refuse to export any Git directory that hasn't explicitly been marked
bcf9626a 34for export this way (unless the `--export-all` parameter is specified). If you
0b444cdb 35pass some directory paths as 'git daemon' arguments, you can further restrict
2707da9c 36the offers to a whitelist comprising of those.
62cd033d 37
355f5412 38By default, only `upload-pack` service is enabled, which serves
0b444cdb
TR
39'git fetch-pack' and 'git ls-remote' clients, which are invoked
40from 'git fetch', 'git pull', and 'git clone'.
355f5412
JH
41
42This is ideally suited for read-only updates, i.e., pulling from
2de9b711 43Git repositories.
7fc9d69f 44
0b444cdb 45An `upload-archive` also exists to serve 'git archive'.
e2b1d1cc 46
7fc9d69f
JH
47OPTIONS
48-------
ce335fe0 49--strict-paths::
4dbd1352
AE
50 Match paths exactly (i.e. don't allow "/foo/repo" when the real path is
51 "/foo/repo.git" or "/foo/repo/.git") and don't do user-relative paths.
0b444cdb 52 'git daemon' will refuse to start when this option is enabled and no
4dbd1352
AE
53 whitelist is specified.
54
62b4698e 55--base-path=<path>::
b21c31c9 56 Remap all the path requests as relative to the given path.
48a8c26c 57 This is sort of "Git root" - if you run 'git daemon' with
b21c31c9 58 '--base-path=/srv/git' on example.com, then if you later try to pull
0b444cdb 59 'git://example.com/hello.git', 'git daemon' will interpret the path
68ed71b5 60 as `/srv/git/hello.git`.
b21c31c9 61
73a7a656
JA
62--base-path-relaxed::
63 If --base-path is enabled and repo lookup fails, with this option
0b444cdb 64 'git daemon' will attempt to lookup without prefixing the base path.
73a7a656
JA
65 This is useful for switching to --base-path usage, while still
66 allowing the old paths.
67
62b4698e 68--interpolated-path=<pathtemplate>::
49ba83fb
JL
69 To support virtual hosting, an interpolated path template can be
70 used to dynamically construct alternate paths. The template
dd467629
JL
71 supports %H for the target hostname as supplied by the client but
72 converted to all lowercase, %CH for the canonical hostname,
73 %IP for the server's IP address, %P for the port number,
49ba83fb 74 and %D for the absolute path of the named repository.
dd467629
JL
75 After interpolation, the path is validated against the directory
76 whitelist.
49ba83fb 77
2707da9c 78--export-all::
48a8c26c 79 Allow pulling from all directories that look like Git repositories
4dbd1352 80 (have the 'objects' and 'refs' subdirectories), even if they
2707da9c
PB
81 do not have the 'git-daemon-export-ok' file.
82
62cd033d 83--inetd::
0c591cac
LW
84 Have the server run as an inetd service. Implies --syslog (may be
85 overridden with `--log-destination=`).
9cddf56e
EFL
86 Incompatible with --detach, --port, --listen, --user and --group
87 options.
dd467629 88
62b4698e 89--listen=<host_or_ipaddr>::
62854410
MH
90 Listen on a specific IP address or hostname. IP addresses can
91 be either an IPv4 address or an IPv6 address if supported. If IPv6
dd467629
JL
92 is not supported, then --listen=hostname is also not supported and
93 --listen must be given an IPv4 address.
3a3a29c1 94 Can be given more than once.
bcf9626a 95 Incompatible with `--inetd` option.
7fc9d69f 96
62b4698e 97--port=<n>::
bcf9626a 98 Listen on an alternative port. Incompatible with `--inetd` option.
7fc9d69f 99
62b4698e 100--init-timeout=<n>::
b8843efc
MS
101 Timeout (in seconds) between the moment the connection is established
102 and the client request is received (typically a rather low value, since
2707da9c
PB
103 that should be basically immediate).
104
62b4698e 105--timeout=<n>::
b8843efc
MS
106 Timeout (in seconds) for specific client sub-requests. This includes
107 the time it takes for the server to process the sub-request and the
108 time spent waiting for the next client's request.
2707da9c 109
62b4698e 110--max-connections=<n>::
3bd62c21
SB
111 Maximum number of concurrent clients, defaults to 32. Set it to
112 zero for no limit.
113
9048fe1c 114--syslog::
0c591cac
LW
115 Short for `--log-destination=syslog`.
116
117--log-destination=<destination>::
118 Send log messages to the specified destination.
119 Note that this option does not imply --verbose,
120 thus by default only error conditions will be logged.
121 The <destination> must be one of:
122+
123--
124stderr::
125 Write to standard error.
126 Note that if `--detach` is specified,
127 the process disconnects from the real standard error,
128 making this destination effectively equivalent to `none`.
129syslog::
130 Write to syslog, using the `git-daemon` identifier.
131none::
132 Disable all logging.
133--
134+
135The default destination is `syslog` if `--inetd` or `--detach` is specified,
136otherwise `stderr`.
9048fe1c 137
3240240f 138--user-path::
62b4698e 139--user-path=<path>::
4fce51cf 140 Allow {tilde}user notation to be used in requests. When
603968d2 141 specified with no parameter, requests to
4fce51cf 142 git://host/{tilde}alice/foo is taken as a request to access
603968d2
JH
143 'foo' repository in the home directory of user `alice`.
144 If `--user-path=path` is specified, the same request is
145 taken as a request to access `path/foo` repository in
146 the home directory of user `alice`.
147
b5cf3c8b
PB
148--verbose::
149 Log details about the incoming connections and requested files.
150
6c35119a
ML
151--reuseaddr::
152 Use SO_REUSEADDR when binding the listening socket.
153 This allows the server to restart without waiting for
154 old connections to time out.
155
156--detach::
157 Detach from the shell. Implies --syslog.
158
62b4698e 159--pid-file=<file>::
bdd73795
JH
160 Save the process id in 'file'. Ignored when the daemon
161 is run under `--inetd`.
6c35119a 162
62b4698e
ŠN
163--user=<user>::
164--group=<group>::
678dac6b
TS
165 Change daemon's uid and gid before entering the service loop.
166 When only `--user` is given without `--group`, the
167 primary group ID for the user is used. The values of
168 the option are given to `getpwnam(3)` and `getgrnam(3)`
169 and numeric IDs are not supported.
170+
171Giving these options is an error when used with `--inetd`; use
172the facility of inet daemon to achieve the same before spawning
0b444cdb 173'git daemon' if needed.
714d2586
JH
174+
175Like many programs that switch user id, the daemon does not reset
176environment variables such as `$HOME` when it runs git programs,
177e.g. `upload-pack` and `receive-pack`. When using this option, you
178may also want to set and export `HOME` to point at the home
179directory of `<user>` before starting the daemon, and make sure any
180Git configuration files in that directory are readable by `<user>`.
678dac6b 181
62b4698e
ŠN
182--enable=<service>::
183--disable=<service>::
355f5412
JH
184 Enable/disable the service site-wide per default. Note
185 that a service disabled site-wide can still be enabled
186 per repository if it is marked overridable and the
62854410 187 repository enables the service with a configuration
355f5412
JH
188 item.
189
62b4698e
ŠN
190--allow-override=<service>::
191--forbid-override=<service>::
355f5412
JH
192 Allow/forbid overriding the site-wide default with per
193 repository configuration. By default, all the services
06ab60c0 194 may be overridden.
355f5412 195
0460ed2c 196--[no-]informative-errors::
d5570f4d
JK
197 When informative errors are turned on, git-daemon will report
198 more verbose errors to the client, differentiating conditions
199 like "no such repository" from "repository not exported". This
200 is more convenient for clients, but may leak information about
201 the existence of unexported repositories. When informative
202 errors are not enabled, all errors report "access denied" to the
203 client. The default is --no-informative-errors.
204
93741e4a
JH
205--access-hook=<path>::
206 Every time a client connects, first run an external command
207 specified by the <path> with service name (e.g. "upload-pack"),
208 path to the repository, hostname (%H), canonical hostname
06ab60c0 209 (%CH), IP address (%IP), and TCP port (%P) as its command-line
93741e4a
JH
210 arguments. The external command can decide to decline the
211 service by exiting with a non-zero status (or to allow it by
212 exiting with a zero status). It can also look at the $REMOTE_ADDR
47d81b5c 213 and `$REMOTE_PORT` environment variables to learn about the
93741e4a
JH
214 requestor when making this decision.
215+
216The external command can optionally write a single line to its
217standard output to be sent to the requestor as an error message when
218it declines the service.
219
4dbd1352
AE
220<directory>::
221 A directory to add to the whitelist of allowed directories. Unless
222 --strict-paths is specified this will also include subdirectories
223 of each named directory.
224
355f5412
JH
225SERVICES
226--------
227
bdd73795 228These services can be globally enabled/disabled using the
06ab60c0 229command-line options of this command. If finer-grained
0b444cdb 230control is desired (e.g. to allow 'git archive' to be run
bdd73795
JH
231against only in a few selected repositories the daemon serves),
232the per-repository configuration file can be used to enable or
233disable them.
234
355f5412 235upload-pack::
0b444cdb 236 This serves 'git fetch-pack' and 'git ls-remote'
355f5412
JH
237 clients. It is enabled by default, but a repository can
238 disable it by setting `daemon.uploadpack` configuration
239 item to `false`.
240
e2b1d1cc 241upload-archive::
0b444cdb 242 This serves 'git archive --remote'. It is disabled by
bdd73795 243 default, but a repository can enable it by setting
74190d23 244 `daemon.uploadarch` configuration item to `true`.
bdd73795
JH
245
246receive-pack::
0b444cdb 247 This serves 'git send-pack' clients, allowing anonymous
bdd73795
JH
248 push. It is disabled by default, as there is _no_
249 authentication in the protocol (in other words, anybody
250 can push anything into the repository, including removal
251 of refs). This is solely meant for a closed LAN setting
252 where everybody is friendly. This service can be
c6056fbc 253 enabled by setting `daemon.receivepack` configuration item to
bdd73795 254 `true`.
e2b1d1cc 255
49ba83fb
JL
256EXAMPLES
257--------
f8a5da6d
CC
258We assume the following in /etc/services::
259+
260------------
261$ grep 9418 /etc/services
262git 9418/tcp # Git Version Control System
263------------
264
0b444cdb
TR
265'git daemon' as inetd server::
266 To set up 'git daemon' as an inetd service that handles any
49ba83fb
JL
267 repository under the whitelisted set of directories, /pub/foo
268 and /pub/bar, place an entry like the following into
269 /etc/inetd all on one line:
270+
271------------------------------------------------
963a653f
JN
272 git stream tcp nowait nobody /usr/bin/git
273 git daemon --inetd --verbose --export-all
49ba83fb
JL
274 /pub/foo /pub/bar
275------------------------------------------------
276
277
0b444cdb
TR
278'git daemon' as inetd server for virtual hosts::
279 To set up 'git daemon' as an inetd service that handles
49ba83fb
JL
280 repositories for different virtual hosts, `www.example.com`
281 and `www.example.org`, place an entry like the following into
282 `/etc/inetd` all on one line:
283+
284------------------------------------------------
963a653f
JN
285 git stream tcp nowait nobody /usr/bin/git
286 git daemon --inetd --verbose --export-all
49ba83fb
JL
287 --interpolated-path=/pub/%H%D
288 /pub/www.example.org/software
289 /pub/www.example.com/software
290 /software
291------------------------------------------------
292+
293In this example, the root-level directory `/pub` will contain
294a subdirectory for each virtual host name supported.
295Further, both hosts advertise repositories simply as
296`git://www.example.com/software/repo.git`. For pre-1.4.0
297clients, a symlink from `/software` into the appropriate
298default repository could be made as well.
299
300
0b444cdb
TR
301'git daemon' as regular daemon for virtual hosts::
302 To set up 'git daemon' as a regular, non-inetd service that
dd467629
JL
303 handles repositories for multiple virtual hosts based on
304 their IP addresses, start the daemon like this:
305+
306------------------------------------------------
963a653f 307 git daemon --verbose --export-all
dd467629
JL
308 --interpolated-path=/pub/%IP/%D
309 /pub/192.168.1.200/software
310 /pub/10.10.220.23/software
311------------------------------------------------
312+
313In this example, the root-level directory `/pub` will contain
314a subdirectory for each virtual host IP address supported.
315Repositories can still be accessed by hostname though, assuming
316they correspond to these IP addresses.
317
f368f5a6 318selectively enable/disable services per repository::
0b444cdb 319 To enable 'git archive --remote' and disable 'git fetch' against
f368f5a6 320 a repository, have the following in the configuration file in the
661c3e9b 321 repository (that is the file 'config' next to `HEAD`, 'refs' and
f368f5a6 322 'objects').
bdd73795
JH
323+
324----------------------------------------------------------------
f368f5a6
JH
325 [daemon]
326 uploadpack = false
74190d23 327 uploadarch = true
bdd73795
JH
328----------------------------------------------------------------
329
330
53ffb878
JH
331ENVIRONMENT
332-----------
0b444cdb 333'git daemon' will set REMOTE_ADDR to the IP address of the client
53ffb878
JH
334that connected to it, if the IP address is available. REMOTE_ADDR will
335be available in the environment of hooks called when
336services are performed.
337
7fc9d69f
JH
338GIT
339---
9e1f0a85 340Part of the linkgit:git[1] suite