blob: a69b3616ec3bdc9686114f4d0b7a851c0ce93339 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-daemon(1)
2=============
3
4NAME
5----
Junio C Hamano076ffcc2013-02-06 05:13:216git-daemon - A really simple server for Git repositories
Junio C Hamano1a4e8412005-12-27 08:17:237
8SYNOPSIS
9--------
Junio C Hamano235a91e2006-01-07 01:13:5810[verse]
Junio C Hamanofce7c7e2008-07-02 03:06:3811'git daemon' [--verbose] [--syslog] [--export-all]
Junio C Hamanod2179ef2010-10-22 04:12:1712 [--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>]
Junio C Hamano3d1b5a12013-05-17 23:34:0219 [--access-hook=<path>] [--[no-]informative-errors]
20 [--inetd |
21 [--listen=<host_or_ipaddr>] [--port=<n>]
22 [--user=<user> [--group=<group>]]]
Junio C Hamanod2179ef2010-10-22 04:12:1723 [<directory>...]
Junio C Hamano1a4e8412005-12-27 08:17:2324
25DESCRIPTION
26-----------
Junio C Hamano076ffcc2013-02-06 05:13:2127A really simple TCP Git daemon that normally listens on port "DEFAULT_GIT_PORT"
Junio C Hamano19ed3682006-09-07 11:44:0828aka 9418. It waits for a connection asking for a service, and will serve
29that service if it is enabled.
Junio C Hamano1a4e8412005-12-27 08:17:2330
31It verifies that the directory has the magic file "git-daemon-export-ok", and
Junio C Hamano076ffcc2013-02-06 05:13:2132it will refuse to export any Git directory that hasn't explicitly been marked
Junio C Hamano1a4e8412005-12-27 08:17:2333for export this way (unless the '--export-all' parameter is specified). If you
Junio C Hamano1aa40d22010-01-21 17:46:4334pass some directory paths as 'git daemon' arguments, you can further restrict
Junio C Hamano1a4e8412005-12-27 08:17:2335the offers to a whitelist comprising of those.
36
Junio C Hamano19ed3682006-09-07 11:44:0837By default, only `upload-pack` service is enabled, which serves
Junio C Hamano1aa40d22010-01-21 17:46:4338'git fetch-pack' and 'git ls-remote' clients, which are invoked
39from 'git fetch', 'git pull', and 'git clone'.
Junio C Hamano19ed3682006-09-07 11:44:0840
41This is ideally suited for read-only updates, i.e., pulling from
Junio C Hamano076ffcc2013-02-06 05:13:2142Git repositories.
Junio C Hamano1a4e8412005-12-27 08:17:2343
Junio C Hamano1aa40d22010-01-21 17:46:4344An `upload-archive` also exists to serve 'git archive'.
Junio C Hamanoa053d542006-10-27 09:29:1345
Junio C Hamano1a4e8412005-12-27 08:17:2346OPTIONS
47-------
48--strict-paths::
49Match paths exactly (i.e. don't allow "/foo/repo" when the real path is
50"/foo/repo.git" or "/foo/repo/.git") and don't do user-relative paths.
Junio C Hamano1aa40d22010-01-21 17:46:4351'git daemon' will refuse to start when this option is enabled and no
Junio C Hamano1a4e8412005-12-27 08:17:2352whitelist is specified.
53
Junio C Hamanod2179ef2010-10-22 04:12:1754--base-path=<path>::
Junio C Hamano4d04a402006-01-09 00:53:2855Remap all the path requests as relative to the given path.
Junio C Hamano076ffcc2013-02-06 05:13:2156This is sort of "Git root" - if you run 'git daemon' with
Junio C Hamano4d04a402006-01-09 00:53:2857'--base-path=/srv/git' on example.com, then if you later try to pull
Junio C Hamano1aa40d22010-01-21 17:46:4358'git://example.com/hello.git', 'git daemon' will interpret the path
Junio C Hamano70fafca2006-02-06 08:02:0159as '/srv/git/hello.git'.
Junio C Hamano4d04a402006-01-09 00:53:2860
Junio C Hamano0ddc94d2007-08-01 08:42:3961--base-path-relaxed::
62If --base-path is enabled and repo lookup fails, with this option
Junio C Hamano1aa40d22010-01-21 17:46:4363'git daemon' will attempt to lookup without prefixing the base path.
Junio C Hamano0ddc94d2007-08-01 08:42:3964This is useful for switching to --base-path usage, while still
65allowing the old paths.
66
Junio C Hamanod2179ef2010-10-22 04:12:1767--interpolated-path=<pathtemplate>::
Junio C Hamano47c1e3c2006-09-25 04:45:5568To support virtual hosting, an interpolated path template can be
69used to dynamically construct alternate paths. The template
Junio C Hamano032c6312006-09-28 07:39:1870supports %H for the target hostname as supplied by the client but
71converted to all lowercase, %CH for the canonical hostname,
72%IP for the server's IP address, %P for the port number,
Junio C Hamano47c1e3c2006-09-25 04:45:5573and %D for the absolute path of the named repository.
Junio C Hamano032c6312006-09-28 07:39:1874After interpolation, the path is validated against the directory
75whitelist.
Junio C Hamano47c1e3c2006-09-25 04:45:5576
Junio C Hamano1a4e8412005-12-27 08:17:2377--export-all::
Junio C Hamano076ffcc2013-02-06 05:13:2178Allow pulling from all directories that look like Git repositories
Junio C Hamano1a4e8412005-12-27 08:17:2379(have the 'objects' and 'refs' subdirectories), even if they
80do not have the 'git-daemon-export-ok' file.
81
82--inetd::
83Have the server run as an inetd service. Implies --syslog.
Junio C Hamano97bcb482010-11-25 03:16:0784Incompatible with --detach, --port, --listen, --user and --group
85options.
Junio C Hamano1a4e8412005-12-27 08:17:2386
Junio C Hamanod2179ef2010-10-22 04:12:1787--listen=<host_or_ipaddr>::
Junio C Hamano4cfa5362009-04-18 23:01:0188Listen on a specific IP address or hostname. IP addresses can
89be either an IPv4 address or an IPv6 address if supported. If IPv6
Junio C Hamano032c6312006-09-28 07:39:1890is not supported, then --listen=hostname is also not supported and
91--listen must be given an IPv4 address.
Junio C Hamano39c7a692010-10-27 06:08:5492Can be given more than once.
Junio C Hamano032c6312006-09-28 07:39:1893Incompatible with '--inetd' option.
94
Junio C Hamanod2179ef2010-10-22 04:12:1795--port=<n>::
Junio C Hamano032c6312006-09-28 07:39:1896Listen on an alternative port. Incompatible with '--inetd' option.
Junio C Hamano1a4e8412005-12-27 08:17:2397
Junio C Hamanod2179ef2010-10-22 04:12:1798--init-timeout=<n>::
Junio C Hamano7bd050f2011-09-22 06:32:2299Timeout (in seconds) between the moment the connection is established
100and the client request is received (typically a rather low value, since
Junio C Hamano1a4e8412005-12-27 08:17:23101that should be basically immediate).
102
Junio C Hamanod2179ef2010-10-22 04:12:17103--timeout=<n>::
Junio C Hamano7bd050f2011-09-22 06:32:22104Timeout (in seconds) for specific client sub-requests. This includes
105the time it takes for the server to process the sub-request and the
106time spent waiting for the next client's request.
Junio C Hamano1a4e8412005-12-27 08:17:23107
Junio C Hamanod2179ef2010-10-22 04:12:17108--max-connections=<n>::
Junio C Hamanofcb740a2008-08-31 06:32:05109Maximum number of concurrent clients, defaults to 32. Set it to
110zero for no limit.
111
Junio C Hamano1a4e8412005-12-27 08:17:23112--syslog::
113Log to syslog instead of stderr. Note that this option does not imply
114--verbose, thus by default only error conditions will be logged.
115
Junio C Hamanoeb415992008-06-08 22:49:47116--user-path::
Junio C Hamanod2179ef2010-10-22 04:12:17117--user-path=<path>::
Junio C Hamano116db352008-12-17 19:48:40118Allow {tilde}user notation to be used in requests. When
Junio C Hamano70fafca2006-02-06 08:02:01119specified with no parameter, requests to
Junio C Hamano116db352008-12-17 19:48:40120git://host/{tilde}alice/foo is taken as a request to access
Junio C Hamano70fafca2006-02-06 08:02:01121'foo' repository in the home directory of user `alice`.
122If `--user-path=path` is specified, the same request is
123taken as a request to access `path/foo` repository in
124the home directory of user `alice`.
125
Junio C Hamano1a4e8412005-12-27 08:17:23126--verbose::
127Log details about the incoming connections and requested files.
128
Junio C Hamanoabb53dc2006-07-28 05:14:12129--reuseaddr::
130Use SO_REUSEADDR when binding the listening socket.
131This allows the server to restart without waiting for
132old connections to time out.
133
134--detach::
135Detach from the shell. Implies --syslog.
136
Junio C Hamanod2179ef2010-10-22 04:12:17137--pid-file=<file>::
Junio C Hamano21e7f9c2007-08-31 07:56:26138Save the process id in 'file'. Ignored when the daemon
139is run under `--inetd`.
Junio C Hamanoabb53dc2006-07-28 05:14:12140
Junio C Hamanod2179ef2010-10-22 04:12:17141--user=<user>::
142--group=<group>::
Junio C Hamano9adfc6a2006-08-28 07:18:38143Change daemon's uid and gid before entering the service loop.
144When only `--user` is given without `--group`, the
145primary group ID for the user is used. The values of
146the option are given to `getpwnam(3)` and `getgrnam(3)`
147and numeric IDs are not supported.
148+
149Giving these options is an error when used with `--inetd`; use
150the facility of inet daemon to achieve the same before spawning
Junio C Hamano1aa40d22010-01-21 17:46:43151'git daemon' if needed.
Junio C Hamanoea3b7522013-04-18 19:37:53152+
153Like many programs that switch user id, the daemon does not reset
154environment variables such as `$HOME` when it runs git programs,
155e.g. `upload-pack` and `receive-pack`. When using this option, you
156may also want to set and export `HOME` to point at the home
157directory of `<user>` before starting the daemon, and make sure any
158Git configuration files in that directory are readable by `<user>`.
Junio C Hamano9adfc6a2006-08-28 07:18:38159
Junio C Hamanod2179ef2010-10-22 04:12:17160--enable=<service>::
161--disable=<service>::
Junio C Hamano19ed3682006-09-07 11:44:08162Enable/disable the service site-wide per default. Note
163that a service disabled site-wide can still be enabled
164per repository if it is marked overridable and the
Junio C Hamano4cfa5362009-04-18 23:01:01165repository enables the service with a configuration
Junio C Hamano19ed3682006-09-07 11:44:08166item.
167
Junio C Hamanod2179ef2010-10-22 04:12:17168--allow-override=<service>::
169--forbid-override=<service>::
Junio C Hamano19ed3682006-09-07 11:44:08170Allow/forbid overriding the site-wide default with per
171repository configuration. By default, all the services
Junio C Hamanoe1aeb5e2014-06-06 19:16:29172may be overridden.
Junio C Hamano19ed3682006-09-07 11:44:08173
Junio C Hamano3d1b5a12013-05-17 23:34:02174--[no-]informative-errors::
Junio C Hamano6231f822011-10-24 05:18:52175When informative errors are turned on, git-daemon will report
176more verbose errors to the client, differentiating conditions
177like "no such repository" from "repository not exported". This
178is more convenient for clients, but may leak information about
179the existence of unexported repositories. When informative
180errors are not enabled, all errors report "access denied" to the
181client. The default is --no-informative-errors.
182
Junio C Hamanof3353932012-09-04 23:16:51183--access-hook=<path>::
184Every time a client connects, first run an external command
185specified by the <path> with service name (e.g. "upload-pack"),
186path to the repository, hostname (%H), canonical hostname
Junio C Hamanoe1aeb5e2014-06-06 19:16:29187(%CH), IP address (%IP), and TCP port (%P) as its command-line
Junio C Hamanof3353932012-09-04 23:16:51188arguments. The external command can decide to decline the
189service by exiting with a non-zero status (or to allow it by
190exiting with a zero status). It can also look at the $REMOTE_ADDR
191and $REMOTE_PORT environment variables to learn about the
192requestor when making this decision.
193+
194The external command can optionally write a single line to its
195standard output to be sent to the requestor as an error message when
196it declines the service.
197
Junio C Hamano1a4e8412005-12-27 08:17:23198<directory>::
199A directory to add to the whitelist of allowed directories. Unless
200--strict-paths is specified this will also include subdirectories
201of each named directory.
202
Junio C Hamano19ed3682006-09-07 11:44:08203SERVICES
204--------
205
Junio C Hamano21e7f9c2007-08-31 07:56:26206These services can be globally enabled/disabled using the
Junio C Hamanoe1aeb5e2014-06-06 19:16:29207command-line options of this command. If finer-grained
Junio C Hamano1aa40d22010-01-21 17:46:43208control is desired (e.g. to allow 'git archive' to be run
Junio C Hamano21e7f9c2007-08-31 07:56:26209against only in a few selected repositories the daemon serves),
210the per-repository configuration file can be used to enable or
211disable them.
212
Junio C Hamano19ed3682006-09-07 11:44:08213upload-pack::
Junio C Hamano1aa40d22010-01-21 17:46:43214This serves 'git fetch-pack' and 'git ls-remote'
Junio C Hamano19ed3682006-09-07 11:44:08215clients. It is enabled by default, but a repository can
216disable it by setting `daemon.uploadpack` configuration
217item to `false`.
218
Junio C Hamanoa053d542006-10-27 09:29:13219upload-archive::
Junio C Hamano1aa40d22010-01-21 17:46:43220This serves 'git archive --remote'. It is disabled by
Junio C Hamano21e7f9c2007-08-31 07:56:26221default, but a repository can enable it by setting
Junio C Hamanofeeb1be2008-05-22 00:53:35222`daemon.uploadarch` configuration item to `true`.
Junio C Hamano21e7f9c2007-08-31 07:56:26223
224receive-pack::
Junio C Hamano1aa40d22010-01-21 17:46:43225This serves 'git send-pack' clients, allowing anonymous
Junio C Hamano21e7f9c2007-08-31 07:56:26226push. It is disabled by default, as there is _no_
227authentication in the protocol (in other words, anybody
228can push anything into the repository, including removal
229of refs). This is solely meant for a closed LAN setting
230where everybody is friendly. This service can be
Junio C Hamanobb300642012-07-22 21:09:14231enabled by setting `daemon.receivepack` configuration item to
Junio C Hamano21e7f9c2007-08-31 07:56:26232`true`.
Junio C Hamanoa053d542006-10-27 09:29:13233
Junio C Hamano47c1e3c2006-09-25 04:45:55234EXAMPLES
235--------
Junio C Hamanoa053d542006-10-27 09:29:13236We assume the following in /etc/services::
237+
238------------
239$ grep 9418 /etc/services
240git 9418/tcp # Git Version Control System
241------------
242
Junio C Hamano1aa40d22010-01-21 17:46:43243'git daemon' as inetd server::
244To set up 'git daemon' as an inetd service that handles any
Junio C Hamano47c1e3c2006-09-25 04:45:55245repository under the whitelisted set of directories, /pub/foo
246and /pub/bar, place an entry like the following into
247/etc/inetd all on one line:
248+
249------------------------------------------------
Junio C Hamanofce7c7e2008-07-02 03:06:38250git stream tcp nowait nobody /usr/bin/git
251git daemon --inetd --verbose --export-all
Junio C Hamano47c1e3c2006-09-25 04:45:55252/pub/foo /pub/bar
253------------------------------------------------
254
255
Junio C Hamano1aa40d22010-01-21 17:46:43256'git daemon' as inetd server for virtual hosts::
257To set up 'git daemon' as an inetd service that handles
Junio C Hamano47c1e3c2006-09-25 04:45:55258repositories for different virtual hosts, `www.example.com`
259and `www.example.org`, place an entry like the following into
260`/etc/inetd` all on one line:
261+
262------------------------------------------------
Junio C Hamanofce7c7e2008-07-02 03:06:38263git stream tcp nowait nobody /usr/bin/git
264git daemon --inetd --verbose --export-all
Junio C Hamano47c1e3c2006-09-25 04:45:55265--interpolated-path=/pub/%H%D
266/pub/www.example.org/software
267/pub/www.example.com/software
268/software
269------------------------------------------------
270+
271In this example, the root-level directory `/pub` will contain
272a subdirectory for each virtual host name supported.
273Further, both hosts advertise repositories simply as
274`git://www.example.com/software/repo.git`. For pre-1.4.0
275clients, a symlink from `/software` into the appropriate
276default repository could be made as well.
277
278
Junio C Hamano1aa40d22010-01-21 17:46:43279'git daemon' as regular daemon for virtual hosts::
280To set up 'git daemon' as a regular, non-inetd service that
Junio C Hamano032c6312006-09-28 07:39:18281handles repositories for multiple virtual hosts based on
282their IP addresses, start the daemon like this:
283+
284------------------------------------------------
Junio C Hamanofce7c7e2008-07-02 03:06:38285git daemon --verbose --export-all
Junio C Hamano032c6312006-09-28 07:39:18286--interpolated-path=/pub/%IP/%D
287/pub/192.168.1.200/software
288/pub/10.10.220.23/software
289------------------------------------------------
290+
291In this example, the root-level directory `/pub` will contain
292a subdirectory for each virtual host IP address supported.
293Repositories can still be accessed by hostname though, assuming
294they correspond to these IP addresses.
295
Junio C Hamanodbb64592007-09-01 11:17:39296selectively enable/disable services per repository::
Junio C Hamano1aa40d22010-01-21 17:46:43297To enable 'git archive --remote' and disable 'git fetch' against
Junio C Hamanodbb64592007-09-01 11:17:39298a repository, have the following in the configuration file in the
299repository (that is the file 'config' next to 'HEAD', 'refs' and
300'objects').
Junio C Hamano21e7f9c2007-08-31 07:56:26301+
302----------------------------------------------------------------
Junio C Hamanodbb64592007-09-01 11:17:39303[daemon]
304uploadpack = false
Junio C Hamanofeeb1be2008-05-22 00:53:35305uploadarch = true
Junio C Hamano21e7f9c2007-08-31 07:56:26306----------------------------------------------------------------
307
308
Junio C Hamano61b12292008-10-27 02:59:10309ENVIRONMENT
310-----------
Junio C Hamano1aa40d22010-01-21 17:46:43311'git daemon' will set REMOTE_ADDR to the IP address of the client
Junio C Hamano61b12292008-10-27 02:59:10312that connected to it, if the IP address is available. REMOTE_ADDR will
313be available in the environment of hooks called when
314services are performed.
315
Junio C Hamano1a4e8412005-12-27 08:17:23316GIT
317---
Junio C Hamanof7c042d2008-06-06 22:50:53318Part of the linkgit:git[1] suite