remote-bzr: fix for disappeared revisions
[git.git] / Documentation / git-daemon.txt
blobbfb106cccd5880f0cd40b03059aa79a5569acb63
1 git-daemon(1)
2 =============
4 NAME
5 ----
6 git-daemon - A really simple server for Git repositories
8 SYNOPSIS
9 --------
10 [verse]
11 'git daemon' [--verbose] [--syslog] [--export-all]
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>]
19              [--access-hook=<path>]
20              [--inetd | [--listen=<host_or_ipaddr>] [--port=<n>] [--user=<user> [--group=<group>]]
21              [<directory>...]
23 DESCRIPTION
24 -----------
25 A really simple TCP Git daemon that normally listens on port "DEFAULT_GIT_PORT"
26 aka 9418.  It waits for a connection asking for a service, and will serve
27 that service if it is enabled.
29 It verifies that the directory has the magic file "git-daemon-export-ok", and
30 it will refuse to export any Git directory that hasn't explicitly been marked
31 for export this way (unless the '--export-all' parameter is specified). If you
32 pass some directory paths as 'git daemon' arguments, you can further restrict
33 the offers to a whitelist comprising of those.
35 By default, only `upload-pack` service is enabled, which serves
36 'git fetch-pack' and 'git ls-remote' clients, which are invoked
37 from 'git fetch', 'git pull', and 'git clone'.
39 This is ideally suited for read-only updates, i.e., pulling from
40 Git repositories.
42 An `upload-archive` also exists to serve 'git archive'.
44 OPTIONS
45 -------
46 --strict-paths::
47         Match paths exactly (i.e. don't allow "/foo/repo" when the real path is
48         "/foo/repo.git" or "/foo/repo/.git") and don't do user-relative paths.
49         'git daemon' will refuse to start when this option is enabled and no
50         whitelist is specified.
52 --base-path=<path>::
53         Remap all the path requests as relative to the given path.
54         This is sort of "Git root" - if you run 'git daemon' with
55         '--base-path=/srv/git' on example.com, then if you later try to pull
56         'git://example.com/hello.git', 'git daemon' will interpret the path
57         as '/srv/git/hello.git'.
59 --base-path-relaxed::
60         If --base-path is enabled and repo lookup fails, with this option
61         'git daemon' will attempt to lookup without prefixing the base path.
62         This is useful for switching to --base-path usage, while still
63         allowing the old paths.
65 --interpolated-path=<pathtemplate>::
66         To support virtual hosting, an interpolated path template can be
67         used to dynamically construct alternate paths.  The template
68         supports %H for the target hostname as supplied by the client but
69         converted to all lowercase, %CH for the canonical hostname,
70         %IP for the server's IP address, %P for the port number,
71         and %D for the absolute path of the named repository.
72         After interpolation, the path is validated against the directory
73         whitelist.
75 --export-all::
76         Allow pulling from all directories that look like Git repositories
77         (have the 'objects' and 'refs' subdirectories), even if they
78         do not have the 'git-daemon-export-ok' file.
80 --inetd::
81         Have the server run as an inetd service. Implies --syslog.
82         Incompatible with --detach, --port, --listen, --user and --group
83         options.
85 --listen=<host_or_ipaddr>::
86         Listen on a specific IP address or hostname.  IP addresses can
87         be either an IPv4 address or an IPv6 address if supported.  If IPv6
88         is not supported, then --listen=hostname is also not supported and
89         --listen must be given an IPv4 address.
90         Can be given more than once.
91         Incompatible with '--inetd' option.
93 --port=<n>::
94         Listen on an alternative port.  Incompatible with '--inetd' option.
96 --init-timeout=<n>::
97         Timeout (in seconds) between the moment the connection is established
98         and the client request is received (typically a rather low value, since
99         that should be basically immediate).
101 --timeout=<n>::
102         Timeout (in seconds) for specific client sub-requests. This includes
103         the time it takes for the server to process the sub-request and the
104         time spent waiting for the next client's request.
106 --max-connections=<n>::
107         Maximum number of concurrent clients, defaults to 32.  Set it to
108         zero for no limit.
110 --syslog::
111         Log to syslog instead of stderr. Note that this option does not imply
112         --verbose, thus by default only error conditions will be logged.
114 --user-path::
115 --user-path=<path>::
116         Allow {tilde}user notation to be used in requests.  When
117         specified with no parameter, requests to
118         git://host/{tilde}alice/foo is taken as a request to access
119         'foo' repository in the home directory of user `alice`.
120         If `--user-path=path` is specified, the same request is
121         taken as a request to access `path/foo` repository in
122         the home directory of user `alice`.
124 --verbose::
125         Log details about the incoming connections and requested files.
127 --reuseaddr::
128         Use SO_REUSEADDR when binding the listening socket.
129         This allows the server to restart without waiting for
130         old connections to time out.
132 --detach::
133         Detach from the shell. Implies --syslog.
135 --pid-file=<file>::
136         Save the process id in 'file'.  Ignored when the daemon
137         is run under `--inetd`.
139 --user=<user>::
140 --group=<group>::
141         Change daemon's uid and gid before entering the service loop.
142         When only `--user` is given without `--group`, the
143         primary group ID for the user is used.  The values of
144         the option are given to `getpwnam(3)` and `getgrnam(3)`
145         and numeric IDs are not supported.
147 Giving these options is an error when used with `--inetd`; use
148 the facility of inet daemon to achieve the same before spawning
149 'git daemon' if needed.
151 Like many programs that switch user id, the daemon does not reset
152 environment variables such as `$HOME` when it runs git programs,
153 e.g. `upload-pack` and `receive-pack`. When using this option, you
154 may also want to set and export `HOME` to point at the home
155 directory of `<user>` before starting the daemon, and make sure any
156 Git configuration files in that directory are readable by `<user>`.
158 --enable=<service>::
159 --disable=<service>::
160         Enable/disable the service site-wide per default.  Note
161         that a service disabled site-wide can still be enabled
162         per repository if it is marked overridable and the
163         repository enables the service with a configuration
164         item.
166 --allow-override=<service>::
167 --forbid-override=<service>::
168         Allow/forbid overriding the site-wide default with per
169         repository configuration.  By default, all the services
170         are overridable.
172 --informative-errors::
173 --no-informative-errors::
174         When informative errors are turned on, git-daemon will report
175         more verbose errors to the client, differentiating conditions
176         like "no such repository" from "repository not exported". This
177         is more convenient for clients, but may leak information about
178         the existence of unexported repositories.  When informative
179         errors are not enabled, all errors report "access denied" to the
180         client. The default is --no-informative-errors.
182 --access-hook=<path>::
183         Every time a client connects, first run an external command
184         specified by the <path> with service name (e.g. "upload-pack"),
185         path to the repository, hostname (%H), canonical hostname
186         (%CH), ip address (%IP), and tcp port (%P) as its command line
187         arguments. The external command can decide to decline the
188         service by exiting with a non-zero status (or to allow it by
189         exiting with a zero status).  It can also look at the $REMOTE_ADDR
190         and $REMOTE_PORT environment variables to learn about the
191         requestor when making this decision.
193 The external command can optionally write a single line to its
194 standard output to be sent to the requestor as an error message when
195 it declines the service.
197 <directory>::
198         A directory to add to the whitelist of allowed directories. Unless
199         --strict-paths is specified this will also include subdirectories
200         of each named directory.
202 SERVICES
203 --------
205 These services can be globally enabled/disabled using the
206 command line options of this command.  If a finer-grained
207 control is desired (e.g. to allow 'git archive' to be run
208 against only in a few selected repositories the daemon serves),
209 the per-repository configuration file can be used to enable or
210 disable them.
212 upload-pack::
213         This serves 'git fetch-pack' and 'git ls-remote'
214         clients.  It is enabled by default, but a repository can
215         disable it by setting `daemon.uploadpack` configuration
216         item to `false`.
218 upload-archive::
219         This serves 'git archive --remote'.  It is disabled by
220         default, but a repository can enable it by setting
221         `daemon.uploadarch` configuration item to `true`.
223 receive-pack::
224         This serves 'git send-pack' clients, allowing anonymous
225         push.  It is disabled by default, as there is _no_
226         authentication in the protocol (in other words, anybody
227         can push anything into the repository, including removal
228         of refs).  This is solely meant for a closed LAN setting
229         where everybody is friendly.  This service can be
230         enabled by setting `daemon.receivepack` configuration item to
231         `true`.
233 EXAMPLES
234 --------
235 We assume the following in /etc/services::
237 ------------
238 $ grep 9418 /etc/services
239 git             9418/tcp                # Git Version Control System
240 ------------
242 'git daemon' as inetd server::
243         To set up 'git daemon' as an inetd service that handles any
244         repository under the whitelisted set of directories, /pub/foo
245         and /pub/bar, place an entry like the following into
246         /etc/inetd all on one line:
248 ------------------------------------------------
249         git stream tcp nowait nobody  /usr/bin/git
250                 git daemon --inetd --verbose --export-all
251                 /pub/foo /pub/bar
252 ------------------------------------------------
255 'git daemon' as inetd server for virtual hosts::
256         To set up 'git daemon' as an inetd service that handles
257         repositories for different virtual hosts, `www.example.com`
258         and `www.example.org`, place an entry like the following into
259         `/etc/inetd` all on one line:
261 ------------------------------------------------
262         git stream tcp nowait nobody /usr/bin/git
263                 git daemon --inetd --verbose --export-all
264                 --interpolated-path=/pub/%H%D
265                 /pub/www.example.org/software
266                 /pub/www.example.com/software
267                 /software
268 ------------------------------------------------
270 In this example, the root-level directory `/pub` will contain
271 a subdirectory for each virtual host name supported.
272 Further, both hosts advertise repositories simply as
273 `git://www.example.com/software/repo.git`.  For pre-1.4.0
274 clients, a symlink from `/software` into the appropriate
275 default repository could be made as well.
278 'git daemon' as regular daemon for virtual hosts::
279         To set up 'git daemon' as a regular, non-inetd service that
280         handles repositories for multiple virtual hosts based on
281         their IP addresses, start the daemon like this:
283 ------------------------------------------------
284         git daemon --verbose --export-all
285                 --interpolated-path=/pub/%IP/%D
286                 /pub/192.168.1.200/software
287                 /pub/10.10.220.23/software
288 ------------------------------------------------
290 In this example, the root-level directory `/pub` will contain
291 a subdirectory for each virtual host IP address supported.
292 Repositories can still be accessed by hostname though, assuming
293 they correspond to these IP addresses.
295 selectively enable/disable services per repository::
296         To enable 'git archive --remote' and disable 'git fetch' against
297         a repository, have the following in the configuration file in the
298         repository (that is the file 'config' next to 'HEAD', 'refs' and
299         'objects').
301 ----------------------------------------------------------------
302         [daemon]
303                 uploadpack = false
304                 uploadarch = true
305 ----------------------------------------------------------------
308 ENVIRONMENT
309 -----------
310 'git daemon' will set REMOTE_ADDR to the IP address of the client
311 that connected to it, if the IP address is available. REMOTE_ADDR will
312 be available in the environment of hooks called when
313 services are performed.
317 Part of the linkgit:git[1] suite