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