blob: 01c9f8eb9eff634fe8ab99908c62207ebecd5e31 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-daemon(1)
2=============
3
4NAME
5----
Junio C Hamano01078922006-03-10 00:31:476git-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 Hamanofcb740a2008-08-31 06:32:0512 [--timeout=n] [--init-timeout=n] [--max-connections=n]
13 [--strict-paths] [--base-path=path] [--base-path-relaxed]
14 [--user-path | --user-path=path]
Junio C Hamanofce7c7e2008-07-02 03:06:3815 [--interpolated-path=pathtemplate]
16 [--reuseaddr] [--detach] [--pid-file=file]
17 [--enable=service] [--disable=service]
Junio C Hamano19ed3682006-09-07 11:44:0818 [--allow-override=service] [--forbid-override=service]
Junio C Hamano032c6312006-09-28 07:39:1819 [--inetd | [--listen=host_or_ipaddr] [--port=n] [--user=user [--group=group]]
20 [directory...]
Junio C Hamano1a4e8412005-12-27 08:17:2321
22DESCRIPTION
23-----------
24A really simple TCP git daemon that normally listens on port "DEFAULT_GIT_PORT"
Junio C Hamano19ed3682006-09-07 11:44:0825aka 9418. It waits for a connection asking for a service, and will serve
26that service if it is enabled.
Junio C Hamano1a4e8412005-12-27 08:17:2327
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
30for export this way (unless the '--export-all' parameter is specified). If you
Junio C Hamano1aa40d22010-01-21 17:46:4331pass some directory paths as 'git daemon' arguments, you can further restrict
Junio C Hamano1a4e8412005-12-27 08:17:2332the offers to a whitelist comprising of those.
33
Junio C Hamano19ed3682006-09-07 11:44:0834By default, only `upload-pack` service is enabled, which serves
Junio C Hamano1aa40d22010-01-21 17:46:4335'git fetch-pack' and 'git ls-remote' clients, which are invoked
36from 'git fetch', 'git pull', and 'git clone'.
Junio C Hamano19ed3682006-09-07 11:44:0837
38This is ideally suited for read-only updates, i.e., pulling from
39git repositories.
Junio C Hamano1a4e8412005-12-27 08:17:2340
Junio C Hamano1aa40d22010-01-21 17:46:4341An `upload-archive` also exists to serve 'git archive'.
Junio C Hamanoa053d542006-10-27 09:29:1342
Junio C Hamano1a4e8412005-12-27 08:17:2343OPTIONS
44-------
45--strict-paths::
46Match 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.
Junio C Hamano1aa40d22010-01-21 17:46:4348'git daemon' will refuse to start when this option is enabled and no
Junio C Hamano1a4e8412005-12-27 08:17:2349whitelist is specified.
50
Junio C Hamano4cfa5362009-04-18 23:01:0151--base-path=path::
Junio C Hamano4d04a402006-01-09 00:53:2852Remap all the path requests as relative to the given path.
Junio C Hamano1aa40d22010-01-21 17:46:4353This is sort of "GIT root" - if you run 'git daemon' with
Junio C Hamano4d04a402006-01-09 00:53:2854'--base-path=/srv/git' on example.com, then if you later try to pull
Junio C Hamano1aa40d22010-01-21 17:46:4355'git://example.com/hello.git', 'git daemon' will interpret the path
Junio C Hamano70fafca2006-02-06 08:02:0156as '/srv/git/hello.git'.
Junio C Hamano4d04a402006-01-09 00:53:2857
Junio C Hamano0ddc94d2007-08-01 08:42:3958--base-path-relaxed::
59If --base-path is enabled and repo lookup fails, with this option
Junio C Hamano1aa40d22010-01-21 17:46:4360'git daemon' will attempt to lookup without prefixing the base path.
Junio C Hamano0ddc94d2007-08-01 08:42:3961This is useful for switching to --base-path usage, while still
62allowing the old paths.
63
Junio C Hamano47c1e3c2006-09-25 04:45:5564--interpolated-path=pathtemplate::
65To support virtual hosting, an interpolated path template can be
66used to dynamically construct alternate paths. The template
Junio C Hamano032c6312006-09-28 07:39:1867supports %H for the target hostname as supplied by the client but
68converted to all lowercase, %CH for the canonical hostname,
69%IP for the server's IP address, %P for the port number,
Junio C Hamano47c1e3c2006-09-25 04:45:5570and %D for the absolute path of the named repository.
Junio C Hamano032c6312006-09-28 07:39:1871After interpolation, the path is validated against the directory
72whitelist.
Junio C Hamano47c1e3c2006-09-25 04:45:5573
Junio C Hamano1a4e8412005-12-27 08:17:2374--export-all::
75Allow pulling from all directories that look like GIT repositories
76(have the 'objects' and 'refs' subdirectories), even if they
77do not have the 'git-daemon-export-ok' file.
78
79--inetd::
80Have the server run as an inetd service. Implies --syslog.
Junio C Hamano032c6312006-09-28 07:39:1881Incompatible with --port, --listen, --user and --group options.
Junio C Hamano1a4e8412005-12-27 08:17:2382
Junio C Hamano032c6312006-09-28 07:39:1883--listen=host_or_ipaddr::
Junio C Hamano4cfa5362009-04-18 23:01:0184Listen on a specific IP address or hostname. IP addresses can
85be either an IPv4 address or an IPv6 address if supported. If IPv6
Junio C Hamano032c6312006-09-28 07:39:1886is not supported, then --listen=hostname is also not supported and
87--listen must be given an IPv4 address.
88Incompatible with '--inetd' option.
89
90--port=n::
91Listen on an alternative port. Incompatible with '--inetd' option.
Junio C Hamano1a4e8412005-12-27 08:17:2392
Junio C Hamano4cfa5362009-04-18 23:01:0193--init-timeout=n::
Junio C Hamano1a4e8412005-12-27 08:17:2394Timeout between the moment the connection is established and the
95client request is received (typically a rather low value, since
96that should be basically immediate).
97
Junio C Hamano4cfa5362009-04-18 23:01:0198--timeout=n::
Junio C Hamano1a4e8412005-12-27 08:17:2399Timeout for specific client sub-requests. This includes the time
Junio C Hamano4cfa5362009-04-18 23:01:01100it takes for the server to process the sub-request and the time spent
101waiting for the next client's request.
Junio C Hamano1a4e8412005-12-27 08:17:23102
Junio C Hamano4cfa5362009-04-18 23:01:01103--max-connections=n::
Junio C Hamanofcb740a2008-08-31 06:32:05104Maximum number of concurrent clients, defaults to 32. Set it to
105zero for no limit.
106
Junio C Hamano1a4e8412005-12-27 08:17:23107--syslog::
108Log to syslog instead of stderr. Note that this option does not imply
109--verbose, thus by default only error conditions will be logged.
110
Junio C Hamanoeb415992008-06-08 22:49:47111--user-path::
112--user-path=path::
Junio C Hamano116db352008-12-17 19:48:40113Allow {tilde}user notation to be used in requests. When
Junio C Hamano70fafca2006-02-06 08:02:01114specified with no parameter, requests to
Junio C Hamano116db352008-12-17 19:48:40115git://host/{tilde}alice/foo is taken as a request to access
Junio C Hamano70fafca2006-02-06 08:02:01116'foo' repository in the home directory of user `alice`.
117If `--user-path=path` is specified, the same request is
118taken as a request to access `path/foo` repository in
119the home directory of user `alice`.
120
Junio C Hamano1a4e8412005-12-27 08:17:23121--verbose::
122Log details about the incoming connections and requested files.
123
Junio C Hamanoabb53dc2006-07-28 05:14:12124--reuseaddr::
125Use SO_REUSEADDR when binding the listening socket.
126This allows the server to restart without waiting for
127old connections to time out.
128
129--detach::
130Detach from the shell. Implies --syslog.
131
132--pid-file=file::
Junio C Hamano21e7f9c2007-08-31 07:56:26133Save the process id in 'file'. Ignored when the daemon
134is run under `--inetd`.
Junio C Hamanoabb53dc2006-07-28 05:14:12135
Junio C Hamanoeb415992008-06-08 22:49:47136--user=user::
137--group=group::
Junio C Hamano9adfc6a2006-08-28 07:18:38138Change daemon's uid and gid before entering the service loop.
139When only `--user` is given without `--group`, the
140primary group ID for the user is used. The values of
141the option are given to `getpwnam(3)` and `getgrnam(3)`
142and 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
Junio C Hamano1aa40d22010-01-21 17:46:43146'git daemon' if needed.
Junio C Hamano9adfc6a2006-08-28 07:18:38147
Junio C Hamanoeb415992008-06-08 22:49:47148--enable=service::
149--disable=service::
Junio C Hamano19ed3682006-09-07 11:44:08150Enable/disable the service site-wide per default. Note
151that a service disabled site-wide can still be enabled
152per repository if it is marked overridable and the
Junio C Hamano4cfa5362009-04-18 23:01:01153repository enables the service with a configuration
Junio C Hamano19ed3682006-09-07 11:44:08154item.
155
Junio C Hamanoeb415992008-06-08 22:49:47156--allow-override=service::
157--forbid-override=service::
Junio C Hamano19ed3682006-09-07 11:44:08158Allow/forbid overriding the site-wide default with per
159repository configuration. By default, all the services
160are overridable.
161
Junio C Hamano1a4e8412005-12-27 08:17:23162<directory>::
163A directory to add to the whitelist of allowed directories. Unless
164--strict-paths is specified this will also include subdirectories
165of each named directory.
166
Junio C Hamano19ed3682006-09-07 11:44:08167SERVICES
168--------
169
Junio C Hamano21e7f9c2007-08-31 07:56:26170These services can be globally enabled/disabled using the
171command line options of this command. If a finer-grained
Junio C Hamano1aa40d22010-01-21 17:46:43172control is desired (e.g. to allow 'git archive' to be run
Junio C Hamano21e7f9c2007-08-31 07:56:26173against only in a few selected repositories the daemon serves),
174the per-repository configuration file can be used to enable or
175disable them.
176
Junio C Hamano19ed3682006-09-07 11:44:08177upload-pack::
Junio C Hamano1aa40d22010-01-21 17:46:43178This serves 'git fetch-pack' and 'git ls-remote'
Junio C Hamano19ed3682006-09-07 11:44:08179clients. It is enabled by default, but a repository can
180disable it by setting `daemon.uploadpack` configuration
181item to `false`.
182
Junio C Hamanoa053d542006-10-27 09:29:13183upload-archive::
Junio C Hamano1aa40d22010-01-21 17:46:43184This serves 'git archive --remote'. It is disabled by
Junio C Hamano21e7f9c2007-08-31 07:56:26185default, but a repository can enable it by setting
Junio C Hamanofeeb1be2008-05-22 00:53:35186`daemon.uploadarch` configuration item to `true`.
Junio C Hamano21e7f9c2007-08-31 07:56:26187
188receive-pack::
Junio C Hamano1aa40d22010-01-21 17:46:43189This serves 'git send-pack' clients, allowing anonymous
Junio C Hamano21e7f9c2007-08-31 07:56:26190push. It is disabled by default, as there is _no_
191authentication in the protocol (in other words, anybody
192can push anything into the repository, including removal
193of refs). This is solely meant for a closed LAN setting
194where everybody is friendly. This service can be
195enabled by `daemon.receivepack` configuration item to
196`true`.
Junio C Hamanoa053d542006-10-27 09:29:13197
Junio C Hamano47c1e3c2006-09-25 04:45:55198EXAMPLES
199--------
Junio C Hamanoa053d542006-10-27 09:29:13200We assume the following in /etc/services::
201+
202------------
203$ grep 9418 /etc/services
204git 9418/tcp # Git Version Control System
205------------
206
Junio C Hamano1aa40d22010-01-21 17:46:43207'git daemon' as inetd server::
208To set up 'git daemon' as an inetd service that handles any
Junio C Hamano47c1e3c2006-09-25 04:45:55209repository under the whitelisted set of directories, /pub/foo
210and /pub/bar, place an entry like the following into
211/etc/inetd all on one line:
212+
213------------------------------------------------
Junio C Hamanofce7c7e2008-07-02 03:06:38214git stream tcp nowait nobody /usr/bin/git
215git daemon --inetd --verbose --export-all
Junio C Hamano47c1e3c2006-09-25 04:45:55216/pub/foo /pub/bar
217------------------------------------------------
218
219
Junio C Hamano1aa40d22010-01-21 17:46:43220'git daemon' as inetd server for virtual hosts::
221To set up 'git daemon' as an inetd service that handles
Junio C Hamano47c1e3c2006-09-25 04:45:55222repositories for different virtual hosts, `www.example.com`
223and `www.example.org`, place an entry like the following into
224`/etc/inetd` all on one line:
225+
226------------------------------------------------
Junio C Hamanofce7c7e2008-07-02 03:06:38227git stream tcp nowait nobody /usr/bin/git
228git daemon --inetd --verbose --export-all
Junio C Hamano47c1e3c2006-09-25 04:45:55229--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
Junio C Hamano1aa40d22010-01-21 17:46:43243'git daemon' as regular daemon for virtual hosts::
244To set up 'git daemon' as a regular, non-inetd service that
Junio C Hamano032c6312006-09-28 07:39:18245handles repositories for multiple virtual hosts based on
246their IP addresses, start the daemon like this:
247+
248------------------------------------------------
Junio C Hamanofce7c7e2008-07-02 03:06:38249git daemon --verbose --export-all
Junio C Hamano032c6312006-09-28 07:39:18250--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
Junio C Hamanodbb64592007-09-01 11:17:39260selectively enable/disable services per repository::
Junio C Hamano1aa40d22010-01-21 17:46:43261To enable 'git archive --remote' and disable 'git fetch' against
Junio C Hamanodbb64592007-09-01 11:17:39262a repository, have the following in the configuration file in the
263repository (that is the file 'config' next to 'HEAD', 'refs' and
264'objects').
Junio C Hamano21e7f9c2007-08-31 07:56:26265+
266----------------------------------------------------------------
Junio C Hamanodbb64592007-09-01 11:17:39267[daemon]
268uploadpack = false
Junio C Hamanofeeb1be2008-05-22 00:53:35269uploadarch = true
Junio C Hamano21e7f9c2007-08-31 07:56:26270----------------------------------------------------------------
271
272
Junio C Hamano61b12292008-10-27 02:59:10273ENVIRONMENT
274-----------
Junio C Hamano1aa40d22010-01-21 17:46:43275'git daemon' will set REMOTE_ADDR to the IP address of the client
Junio C Hamano61b12292008-10-27 02:59:10276that 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
Junio C Hamano1a4e8412005-12-27 08:17:23282Author
283------
284Written by Linus Torvalds <torvalds@osdl.org>, YOSHIFUJI Hideaki
285<yoshfuji@linux-ipv6.org> and the git-list <git@vger.kernel.org>
286
287Documentation
288--------------
289Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
290
291GIT
292---
Junio C Hamanof7c042d2008-06-06 22:50:53293Part of the linkgit:git[1] suite