blob: 56d54a489875652e754f7cd16ee5a77c2f5e5202 [file] [log] [blame]
Junio C Hamano7fc9d692005-08-23 01:49:47 -07001git-daemon(1)
2=============
3
4NAME
5----
Thomas Ackermann2de9b712013-01-21 20:17:53 +01006git-daemon - A really simple server for Git repositories
Junio C Hamano7fc9d692005-08-23 01:49:47 -07007
8SYNOPSIS
9--------
Jonas Fonseca353ce812005-12-31 18:37:15 +010010[verse]
Jonathan Niederb1889c32008-06-30 01:09:04 -050011'git daemon' [--verbose] [--syslog] [--export-all]
Štěpán Němec62b46982010-10-08 19:31:15 +020012 [--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>]
Felipe Contreras0460ed22013-05-08 20:16:55 -050019 [--access-hook=<path>] [--[no-]informative-errors]
20 [--inetd |
21 [--listen=<host_or_ipaddr>] [--port=<n>]
22 [--user=<user> [--group=<group>]]]
Lucas Werkmeister0c591ca2018-02-04 19:30:37 +010023 [--log-destination=(stderr|syslog|none)]
Štěpán Němec62b46982010-10-08 19:31:15 +020024 [<directory>...]
Junio C Hamano7fc9d692005-08-23 01:49:47 -070025
26DESCRIPTION
27-----------
Thomas Ackermann2de9b712013-01-21 20:17:53 +010028A really simple TCP Git daemon that normally listens on port "DEFAULT_GIT_PORT"
Junio C Hamano355f5412006-08-20 19:32:43 -070029aka 9418. It waits for a connection asking for a service, and will serve
30that service if it is enabled.
A Large Angry SCM62cd0332005-08-29 22:31:22 -040031
32It verifies that the directory has the magic file "git-daemon-export-ok", and
Thomas Ackermann2de9b712013-01-21 20:17:53 +010033it will refuse to export any Git directory that hasn't explicitly been marked
Matthieu Moybcf96262016-06-28 13:40:11 +020034for export this way (unless the `--export-all` parameter is specified). If you
Thomas Rast0b444cd2010-01-10 00:33:00 +010035pass some directory paths as 'git daemon' arguments, you can further restrict
Petr Baudis2707da92005-10-21 02:28:45 +020036the offers to a whitelist comprising of those.
A Large Angry SCM62cd0332005-08-29 22:31:22 -040037
Junio C Hamano355f5412006-08-20 19:32:43 -070038By default, only `upload-pack` service is enabled, which serves
Thomas Rast0b444cd2010-01-10 00:33:00 +010039'git fetch-pack' and 'git ls-remote' clients, which are invoked
40from 'git fetch', 'git pull', and 'git clone'.
Junio C Hamano355f5412006-08-20 19:32:43 -070041
42This is ideally suited for read-only updates, i.e., pulling from
Thomas Ackermann2de9b712013-01-21 20:17:53 +010043Git repositories.
Junio C Hamano7fc9d692005-08-23 01:49:47 -070044
Thomas Rast0b444cd2010-01-10 00:33:00 +010045An `upload-archive` also exists to serve 'git archive'.
Christian Coudere2b1d1c2006-10-27 06:59:18 +020046
Junio C Hamano7fc9d692005-08-23 01:49:47 -070047OPTIONS
48-------
Junio C Hamanoce335fe2005-11-21 01:21:18 -080049--strict-paths::
Andreas Ericsson4dbd1352005-11-17 20:37:14 +010050 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.
Thomas Rast0b444cd2010-01-10 00:33:00 +010052 'git daemon' will refuse to start when this option is enabled and no
Andreas Ericsson4dbd1352005-11-17 20:37:14 +010053 whitelist is specified.
54
Štěpán Němec62b46982010-10-08 19:31:15 +020055--base-path=<path>::
Petr Baudisb21c31c2005-12-23 02:27:40 +010056 Remap all the path requests as relative to the given path.
Thomas Ackermann48a8c262013-01-21 20:16:20 +010057 This is sort of "Git root" - if you run 'git daemon' with
Petr Baudisb21c31c2005-12-23 02:27:40 +010058 '--base-path=/srv/git' on example.com, then if you later try to pull
Thomas Rast0b444cd2010-01-10 00:33:00 +010059 'git://example.com/hello.git', 'git daemon' will interpret the path
Junio C Hamano603968d2006-02-04 22:27:29 -080060 as '/srv/git/hello.git'.
Petr Baudisb21c31c2005-12-23 02:27:40 +010061
Jens Axboe73a7a652007-07-27 14:00:29 -070062--base-path-relaxed::
63 If --base-path is enabled and repo lookup fails, with this option
Thomas Rast0b444cd2010-01-10 00:33:00 +010064 'git daemon' will attempt to lookup without prefixing the base path.
Jens Axboe73a7a652007-07-27 14:00:29 -070065 This is useful for switching to --base-path usage, while still
66 allowing the old paths.
67
Štěpán Němec62b46982010-10-08 19:31:15 +020068--interpolated-path=<pathtemplate>::
Jon Loeliger49ba83f2006-09-19 20:31:51 -050069 To support virtual hosting, an interpolated path template can be
70 used to dynamically construct alternate paths. The template
Jon Loeligerdd467622006-09-26 09:47:43 -050071 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,
Jon Loeliger49ba83f2006-09-19 20:31:51 -050074 and %D for the absolute path of the named repository.
Jon Loeligerdd467622006-09-26 09:47:43 -050075 After interpolation, the path is validated against the directory
76 whitelist.
Jon Loeliger49ba83f2006-09-19 20:31:51 -050077
Petr Baudis2707da92005-10-21 02:28:45 +020078--export-all::
Thomas Ackermann48a8c262013-01-21 20:16:20 +010079 Allow pulling from all directories that look like Git repositories
Andreas Ericsson4dbd1352005-11-17 20:37:14 +010080 (have the 'objects' and 'refs' subdirectories), even if they
Petr Baudis2707da92005-10-21 02:28:45 +020081 do not have the 'git-daemon-export-ok' file.
82
A Large Angry SCM62cd0332005-08-29 22:31:22 -040083--inetd::
Lucas Werkmeister0c591ca2018-02-04 19:30:37 +010084 Have the server run as an inetd service. Implies --syslog (may be
85 overridden with `--log-destination=`).
Erik Faye-Lund9cddf562010-11-04 02:35:23 +010086 Incompatible with --detach, --port, --listen, --user and --group
87 options.
Junio C Hamano7fc9d692005-08-23 01:49:47 -070088
Štěpán Němec62b46982010-10-08 19:31:15 +020089--listen=<host_or_ipaddr>::
Markus Heidelberg62854412009-04-18 11:46:06 +020090 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
Jon Loeligerdd467622006-09-26 09:47:43 -050092 is not supported, then --listen=hostname is also not supported and
93 --listen must be given an IPv4 address.
Alexander Sulfrian3a3a29c2010-08-30 13:30:51 +020094 Can be given more than once.
Matthieu Moybcf96262016-06-28 13:40:11 +020095 Incompatible with `--inetd` option.
Jon Loeligerdd467622006-09-26 09:47:43 -050096
Štěpán Němec62b46982010-10-08 19:31:15 +020097--port=<n>::
Matthieu Moybcf96262016-06-28 13:40:11 +020098 Listen on an alternative port. Incompatible with `--inetd` option.
Junio C Hamano7fc9d692005-08-23 01:49:47 -070099
Štěpán Němec62b46982010-10-08 19:31:15 +0200100--init-timeout=<n>::
Michael Stapelbergb8843ef2011-08-27 16:29:20 +0200101 Timeout (in seconds) between the moment the connection is established
102 and the client request is received (typically a rather low value, since
Petr Baudis2707da92005-10-21 02:28:45 +0200103 that should be basically immediate).
104
Štěpán Němec62b46982010-10-08 19:31:15 +0200105--timeout=<n>::
Michael Stapelbergb8843ef2011-08-27 16:29:20 +0200106 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.
Petr Baudis2707da92005-10-21 02:28:45 +0200109
Štěpán Němec62b46982010-10-08 19:31:15 +0200110--max-connections=<n>::
Stephen R. van den Berg3bd62c22008-08-14 20:02:20 +0200111 Maximum number of concurrent clients, defaults to 32. Set it to
112 zero for no limit.
113
Petr Baudis9048fe12005-09-24 16:13:01 +0200114--syslog::
Lucas Werkmeister0c591ca2018-02-04 19:30:37 +0100115 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`.
Petr Baudis9048fe12005-09-24 16:13:01 +0200137
Stephan Beyer32402402008-06-08 03:36:09 +0200138--user-path::
Štěpán Němec62b46982010-10-08 19:31:15 +0200139--user-path=<path>::
Miklos Vajna4fce51c2008-12-16 16:48:12 +0100140 Allow {tilde}user notation to be used in requests. When
Junio C Hamano603968d2006-02-04 22:27:29 -0800141 specified with no parameter, requests to
Miklos Vajna4fce51c2008-12-16 16:48:12 +0100142 git://host/{tilde}alice/foo is taken as a request to access
Junio C Hamano603968d2006-02-04 22:27:29 -0800143 '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
Petr Baudisb5cf3c82005-09-24 16:12:58 +0200148--verbose::
149 Log details about the incoming connections and requested files.
150
Matthias Lederhofer6c351192006-07-14 17:53:29 +0200151--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
Štěpán Němec62b46982010-10-08 19:31:15 +0200159--pid-file=<file>::
Junio C Hamanobdd73792007-08-29 03:32:12 -0700160 Save the process id in 'file'. Ignored when the daemon
161 is run under `--inetd`.
Matthias Lederhofer6c351192006-07-14 17:53:29 +0200162
Štěpán Němec62b46982010-10-08 19:31:15 +0200163--user=<user>::
164--group=<group>::
Tilman Sauerbeck678dac62006-08-22 19:37:41 +0200165 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
Thomas Rast0b444cd2010-01-10 00:33:00 +0100173'git daemon' if needed.
Junio C Hamano714d2582013-04-12 09:08:31 -0700174+
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>`.
Tilman Sauerbeck678dac62006-08-22 19:37:41 +0200181
Štěpán Němec62b46982010-10-08 19:31:15 +0200182--enable=<service>::
183--disable=<service>::
Junio C Hamano355f5412006-08-20 19:32:43 -0700184 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
Markus Heidelberg62854412009-04-18 11:46:06 +0200187 repository enables the service with a configuration
Junio C Hamano355f5412006-08-20 19:32:43 -0700188 item.
189
Štěpán Němec62b46982010-10-08 19:31:15 +0200190--allow-override=<service>::
191--forbid-override=<service>::
Junio C Hamano355f5412006-08-20 19:32:43 -0700192 Allow/forbid overriding the site-wide default with per
193 repository configuration. By default, all the services
Jason St. John06ab60c2014-05-21 14:52:26 -0400194 may be overridden.
Junio C Hamano355f5412006-08-20 19:32:43 -0700195
Felipe Contreras0460ed22013-05-08 20:16:55 -0500196--[no-]informative-errors::
Jeff Kingd5570f42011-10-14 17:19:21 -0400197 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
Junio C Hamano93741e42012-08-14 11:37:51 -0700205--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
Jason St. John06ab60c2014-05-21 14:52:26 -0400209 (%CH), IP address (%IP), and TCP port (%P) as its command-line
Junio C Hamano93741e42012-08-14 11:37:51 -0700210 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
Tom Russello47d81b52016-06-08 00:35:07 +0200213 and `$REMOTE_PORT` environment variables to learn about the
Junio C Hamano93741e42012-08-14 11:37:51 -0700214 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
Andreas Ericsson4dbd1352005-11-17 20:37:14 +0100220<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
Junio C Hamano355f5412006-08-20 19:32:43 -0700225SERVICES
226--------
227
Junio C Hamanobdd73792007-08-29 03:32:12 -0700228These services can be globally enabled/disabled using the
Jason St. John06ab60c2014-05-21 14:52:26 -0400229command-line options of this command. If finer-grained
Thomas Rast0b444cd2010-01-10 00:33:00 +0100230control is desired (e.g. to allow 'git archive' to be run
Junio C Hamanobdd73792007-08-29 03:32:12 -0700231against only in a few selected repositories the daemon serves),
232the per-repository configuration file can be used to enable or
233disable them.
234
Junio C Hamano355f5412006-08-20 19:32:43 -0700235upload-pack::
Thomas Rast0b444cd2010-01-10 00:33:00 +0100236 This serves 'git fetch-pack' and 'git ls-remote'
Junio C Hamano355f5412006-08-20 19:32:43 -0700237 clients. It is enabled by default, but a repository can
238 disable it by setting `daemon.uploadpack` configuration
239 item to `false`.
240
Christian Coudere2b1d1c2006-10-27 06:59:18 +0200241upload-archive::
Thomas Rast0b444cd2010-01-10 00:33:00 +0100242 This serves 'git archive --remote'. It is disabled by
Junio C Hamanobdd73792007-08-29 03:32:12 -0700243 default, but a repository can enable it by setting
Jeff King74190d22008-05-19 16:08:33 -0400244 `daemon.uploadarch` configuration item to `true`.
Junio C Hamanobdd73792007-08-29 03:32:12 -0700245
246receive-pack::
Thomas Rast0b444cd2010-01-10 00:33:00 +0100247 This serves 'git send-pack' clients, allowing anonymous
Junio C Hamanobdd73792007-08-29 03:32:12 -0700248 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
Michael Schubertc6056fb2012-07-16 13:50:31 +0200253 enabled by setting `daemon.receivepack` configuration item to
Junio C Hamanobdd73792007-08-29 03:32:12 -0700254 `true`.
Christian Coudere2b1d1c2006-10-27 06:59:18 +0200255
Jon Loeliger49ba83f2006-09-19 20:31:51 -0500256EXAMPLES
257--------
Christian Couderf8a5da62006-10-27 07:00:57 +0200258We assume the following in /etc/services::
259+
260------------
261$ grep 9418 /etc/services
262git 9418/tcp # Git Version Control System
263------------
264
Thomas Rast0b444cd2010-01-10 00:33:00 +0100265'git daemon' as inetd server::
266 To set up 'git daemon' as an inetd service that handles any
Jon Loeliger49ba83f2006-09-19 20:31:51 -0500267 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------------------------------------------------
Jonathan Nieder963a6532008-06-30 17:15:57 -0500272 git stream tcp nowait nobody /usr/bin/git
273 git daemon --inetd --verbose --export-all
Jon Loeliger49ba83f2006-09-19 20:31:51 -0500274 /pub/foo /pub/bar
275------------------------------------------------
276
277
Thomas Rast0b444cd2010-01-10 00:33:00 +0100278'git daemon' as inetd server for virtual hosts::
279 To set up 'git daemon' as an inetd service that handles
Jon Loeliger49ba83f2006-09-19 20:31:51 -0500280 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------------------------------------------------
Jonathan Nieder963a6532008-06-30 17:15:57 -0500285 git stream tcp nowait nobody /usr/bin/git
286 git daemon --inetd --verbose --export-all
Jon Loeliger49ba83f2006-09-19 20:31:51 -0500287 --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
Thomas Rast0b444cd2010-01-10 00:33:00 +0100301'git daemon' as regular daemon for virtual hosts::
302 To set up 'git daemon' as a regular, non-inetd service that
Jon Loeligerdd467622006-09-26 09:47:43 -0500303 handles repositories for multiple virtual hosts based on
304 their IP addresses, start the daemon like this:
305+
306------------------------------------------------
Jonathan Nieder963a6532008-06-30 17:15:57 -0500307 git daemon --verbose --export-all
Jon Loeligerdd467622006-09-26 09:47:43 -0500308 --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
Junio C Hamanof368f5a2007-09-01 04:01:54 -0700318selectively enable/disable services per repository::
Thomas Rast0b444cd2010-01-10 00:33:00 +0100319 To enable 'git archive --remote' and disable 'git fetch' against
Junio C Hamanof368f5a2007-09-01 04:01:54 -0700320 a repository, have the following in the configuration file in the
Matthieu Moy661c3e92016-06-28 13:40:15 +0200321 repository (that is the file 'config' next to `HEAD`, 'refs' and
Junio C Hamanof368f5a2007-09-01 04:01:54 -0700322 'objects').
Junio C Hamanobdd73792007-08-29 03:32:12 -0700323+
324----------------------------------------------------------------
Junio C Hamanof368f5a2007-09-01 04:01:54 -0700325 [daemon]
326 uploadpack = false
Jeff King74190d22008-05-19 16:08:33 -0400327 uploadarch = true
Junio C Hamanobdd73792007-08-29 03:32:12 -0700328----------------------------------------------------------------
329
330
Joey Hess53ffb872008-10-24 01:48:50 -0400331ENVIRONMENT
332-----------
Thomas Rast0b444cd2010-01-10 00:33:00 +0100333'git daemon' will set REMOTE_ADDR to the IP address of the client
Joey Hess53ffb872008-10-24 01:48:50 -0400334that 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
Junio C Hamano7fc9d692005-08-23 01:49:47 -0700338GIT
339---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200340Part of the linkgit:git[1] suite