Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | git-daemon(1) |
| 2 | ============= |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 0107892 | 2006-03-10 00:31:47 | [diff] [blame] | 6 | git-daemon - A really simple server for git repositories |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 10 | [verse] |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 11 | 'git daemon' [--verbose] [--syslog] [--export-all] |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 12 | [--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 Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 15 | [--interpolated-path=pathtemplate] |
| 16 | [--reuseaddr] [--detach] [--pid-file=file] |
| 17 | [--enable=service] [--disable=service] |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 18 | [--allow-override=service] [--forbid-override=service] |
Junio C Hamano | 032c631 | 2006-09-28 07:39:18 | [diff] [blame] | 19 | [--inetd | [--listen=host_or_ipaddr] [--port=n] [--user=user [--group=group]] |
| 20 | [directory...] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 21 | |
| 22 | DESCRIPTION |
| 23 | ----------- |
| 24 | A really simple TCP git daemon that normally listens on port "DEFAULT_GIT_PORT" |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 25 | aka 9418. It waits for a connection asking for a service, and will serve |
| 26 | that service if it is enabled. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 27 | |
| 28 | It verifies that the directory has the magic file "git-daemon-export-ok", and |
| 29 | it will refuse to export any git directory that hasn't explicitly been marked |
| 30 | for export this way (unless the '--export-all' parameter is specified). If you |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 31 | pass some directory paths as 'git daemon' arguments, you can further restrict |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 32 | the offers to a whitelist comprising of those. |
| 33 | |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 34 | By default, only `upload-pack` service is enabled, which serves |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 35 | 'git fetch-pack' and 'git ls-remote' clients, which are invoked |
| 36 | from 'git fetch', 'git pull', and 'git clone'. |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 37 | |
| 38 | This is ideally suited for read-only updates, i.e., pulling from |
| 39 | git repositories. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 40 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 41 | An `upload-archive` also exists to serve 'git archive'. |
Junio C Hamano | a053d54 | 2006-10-27 09:29:13 | [diff] [blame] | 42 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 43 | OPTIONS |
| 44 | ------- |
| 45 | --strict-paths:: |
| 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. |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 48 | 'git daemon' will refuse to start when this option is enabled and no |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 49 | whitelist is specified. |
| 50 | |
Junio C Hamano | 4cfa536 | 2009-04-18 23:01:01 | [diff] [blame] | 51 | --base-path=path:: |
Junio C Hamano | 4d04a40 | 2006-01-09 00:53:28 | [diff] [blame] | 52 | Remap all the path requests as relative to the given path. |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 53 | This is sort of "GIT root" - if you run 'git daemon' with |
Junio C Hamano | 4d04a40 | 2006-01-09 00:53:28 | [diff] [blame] | 54 | '--base-path=/srv/git' on example.com, then if you later try to pull |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 55 | 'git://example.com/hello.git', 'git daemon' will interpret the path |
Junio C Hamano | 70fafca | 2006-02-06 08:02:01 | [diff] [blame] | 56 | as '/srv/git/hello.git'. |
Junio C Hamano | 4d04a40 | 2006-01-09 00:53:28 | [diff] [blame] | 57 | |
Junio C Hamano | 0ddc94d | 2007-08-01 08:42:39 | [diff] [blame] | 58 | --base-path-relaxed:: |
| 59 | If --base-path is enabled and repo lookup fails, with this option |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 60 | 'git daemon' will attempt to lookup without prefixing the base path. |
Junio C Hamano | 0ddc94d | 2007-08-01 08:42:39 | [diff] [blame] | 61 | This is useful for switching to --base-path usage, while still |
| 62 | allowing the old paths. |
| 63 | |
Junio C Hamano | 47c1e3c | 2006-09-25 04:45:55 | [diff] [blame] | 64 | --interpolated-path=pathtemplate:: |
| 65 | To support virtual hosting, an interpolated path template can be |
| 66 | used to dynamically construct alternate paths. The template |
Junio C Hamano | 032c631 | 2006-09-28 07:39:18 | [diff] [blame] | 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, |
Junio C Hamano | 47c1e3c | 2006-09-25 04:45:55 | [diff] [blame] | 70 | and %D for the absolute path of the named repository. |
Junio C Hamano | 032c631 | 2006-09-28 07:39:18 | [diff] [blame] | 71 | After interpolation, the path is validated against the directory |
| 72 | whitelist. |
Junio C Hamano | 47c1e3c | 2006-09-25 04:45:55 | [diff] [blame] | 73 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 74 | --export-all:: |
| 75 | Allow pulling from all directories that look like GIT repositories |
| 76 | (have the 'objects' and 'refs' subdirectories), even if they |
| 77 | do not have the 'git-daemon-export-ok' file. |
| 78 | |
| 79 | --inetd:: |
| 80 | Have the server run as an inetd service. Implies --syslog. |
Junio C Hamano | 032c631 | 2006-09-28 07:39:18 | [diff] [blame] | 81 | Incompatible with --port, --listen, --user and --group options. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 82 | |
Junio C Hamano | 032c631 | 2006-09-28 07:39:18 | [diff] [blame] | 83 | --listen=host_or_ipaddr:: |
Junio C Hamano | 4cfa536 | 2009-04-18 23:01:01 | [diff] [blame] | 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 |
Junio C Hamano | 032c631 | 2006-09-28 07:39:18 | [diff] [blame] | 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. |
| 89 | |
| 90 | --port=n:: |
| 91 | Listen on an alternative port. Incompatible with '--inetd' option. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 92 | |
Junio C Hamano | 4cfa536 | 2009-04-18 23:01:01 | [diff] [blame] | 93 | --init-timeout=n:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 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 | |
Junio C Hamano | 4cfa536 | 2009-04-18 23:01:01 | [diff] [blame] | 98 | --timeout=n:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 99 | Timeout for specific client sub-requests. This includes the time |
Junio C Hamano | 4cfa536 | 2009-04-18 23:01:01 | [diff] [blame] | 100 | it takes for the server to process the sub-request and the time spent |
| 101 | waiting for the next client's request. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 102 | |
Junio C Hamano | 4cfa536 | 2009-04-18 23:01:01 | [diff] [blame] | 103 | --max-connections=n:: |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 104 | Maximum number of concurrent clients, defaults to 32. Set it to |
| 105 | zero for no limit. |
| 106 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 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 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 111 | --user-path:: |
| 112 | --user-path=path:: |
Junio C Hamano | 116db35 | 2008-12-17 19:48:40 | [diff] [blame] | 113 | Allow {tilde}user notation to be used in requests. When |
Junio C Hamano | 70fafca | 2006-02-06 08:02:01 | [diff] [blame] | 114 | specified with no parameter, requests to |
Junio C Hamano | 116db35 | 2008-12-17 19:48:40 | [diff] [blame] | 115 | git://host/{tilde}alice/foo is taken as a request to access |
Junio C Hamano | 70fafca | 2006-02-06 08:02:01 | [diff] [blame] | 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 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 121 | --verbose:: |
| 122 | Log details about the incoming connections and requested files. |
| 123 | |
Junio C Hamano | abb53dc | 2006-07-28 05:14:12 | [diff] [blame] | 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:: |
Junio C Hamano | 21e7f9c | 2007-08-31 07:56:26 | [diff] [blame] | 133 | Save the process id in 'file'. Ignored when the daemon |
| 134 | is run under `--inetd`. |
Junio C Hamano | abb53dc | 2006-07-28 05:14:12 | [diff] [blame] | 135 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 136 | --user=user:: |
| 137 | --group=group:: |
Junio C Hamano | 9adfc6a | 2006-08-28 07:18:38 | [diff] [blame] | 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 | + |
| 144 | Giving these options is an error when used with `--inetd`; use |
| 145 | the facility of inet daemon to achieve the same before spawning |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 146 | 'git daemon' if needed. |
Junio C Hamano | 9adfc6a | 2006-08-28 07:18:38 | [diff] [blame] | 147 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 148 | --enable=service:: |
| 149 | --disable=service:: |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 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 |
Junio C Hamano | 4cfa536 | 2009-04-18 23:01:01 | [diff] [blame] | 153 | repository enables the service with a configuration |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 154 | item. |
| 155 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 156 | --allow-override=service:: |
| 157 | --forbid-override=service:: |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 158 | Allow/forbid overriding the site-wide default with per |
| 159 | repository configuration. By default, all the services |
| 160 | are overridable. |
| 161 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 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 | |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 167 | SERVICES |
| 168 | -------- |
| 169 | |
Junio C Hamano | 21e7f9c | 2007-08-31 07:56:26 | [diff] [blame] | 170 | These services can be globally enabled/disabled using the |
| 171 | command line options of this command. If a finer-grained |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 172 | control is desired (e.g. to allow 'git archive' to be run |
Junio C Hamano | 21e7f9c | 2007-08-31 07:56:26 | [diff] [blame] | 173 | against only in a few selected repositories the daemon serves), |
| 174 | the per-repository configuration file can be used to enable or |
| 175 | disable them. |
| 176 | |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 177 | upload-pack:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 178 | This serves 'git fetch-pack' and 'git ls-remote' |
Junio C Hamano | 19ed368 | 2006-09-07 11:44:08 | [diff] [blame] | 179 | clients. It is enabled by default, but a repository can |
| 180 | disable it by setting `daemon.uploadpack` configuration |
| 181 | item to `false`. |
| 182 | |
Junio C Hamano | a053d54 | 2006-10-27 09:29:13 | [diff] [blame] | 183 | upload-archive:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 184 | This serves 'git archive --remote'. It is disabled by |
Junio C Hamano | 21e7f9c | 2007-08-31 07:56:26 | [diff] [blame] | 185 | default, but a repository can enable it by setting |
Junio C Hamano | feeb1be | 2008-05-22 00:53:35 | [diff] [blame] | 186 | `daemon.uploadarch` configuration item to `true`. |
Junio C Hamano | 21e7f9c | 2007-08-31 07:56:26 | [diff] [blame] | 187 | |
| 188 | receive-pack:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 189 | This serves 'git send-pack' clients, allowing anonymous |
Junio C Hamano | 21e7f9c | 2007-08-31 07:56:26 | [diff] [blame] | 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`. |
Junio C Hamano | a053d54 | 2006-10-27 09:29:13 | [diff] [blame] | 197 | |
Junio C Hamano | 47c1e3c | 2006-09-25 04:45:55 | [diff] [blame] | 198 | EXAMPLES |
| 199 | -------- |
Junio C Hamano | a053d54 | 2006-10-27 09:29:13 | [diff] [blame] | 200 | We assume the following in /etc/services:: |
| 201 | + |
| 202 | ------------ |
| 203 | $ grep 9418 /etc/services |
| 204 | git 9418/tcp # Git Version Control System |
| 205 | ------------ |
| 206 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 207 | 'git daemon' as inetd server:: |
| 208 | To set up 'git daemon' as an inetd service that handles any |
Junio C Hamano | 47c1e3c | 2006-09-25 04:45:55 | [diff] [blame] | 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 | ------------------------------------------------ |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 214 | git stream tcp nowait nobody /usr/bin/git |
| 215 | git daemon --inetd --verbose --export-all |
Junio C Hamano | 47c1e3c | 2006-09-25 04:45:55 | [diff] [blame] | 216 | /pub/foo /pub/bar |
| 217 | ------------------------------------------------ |
| 218 | |
| 219 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 220 | 'git daemon' as inetd server for virtual hosts:: |
| 221 | To set up 'git daemon' as an inetd service that handles |
Junio C Hamano | 47c1e3c | 2006-09-25 04:45:55 | [diff] [blame] | 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 | ------------------------------------------------ |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 227 | git stream tcp nowait nobody /usr/bin/git |
| 228 | git daemon --inetd --verbose --export-all |
Junio C Hamano | 47c1e3c | 2006-09-25 04:45:55 | [diff] [blame] | 229 | --interpolated-path=/pub/%H%D |
| 230 | /pub/www.example.org/software |
| 231 | /pub/www.example.com/software |
| 232 | /software |
| 233 | ------------------------------------------------ |
| 234 | + |
| 235 | In this example, the root-level directory `/pub` will contain |
| 236 | a subdirectory for each virtual host name supported. |
| 237 | Further, both hosts advertise repositories simply as |
| 238 | `git://www.example.com/software/repo.git`. For pre-1.4.0 |
| 239 | clients, a symlink from `/software` into the appropriate |
| 240 | default repository could be made as well. |
| 241 | |
| 242 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 243 | 'git daemon' as regular daemon for virtual hosts:: |
| 244 | To set up 'git daemon' as a regular, non-inetd service that |
Junio C Hamano | 032c631 | 2006-09-28 07:39:18 | [diff] [blame] | 245 | handles repositories for multiple virtual hosts based on |
| 246 | their IP addresses, start the daemon like this: |
| 247 | + |
| 248 | ------------------------------------------------ |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 249 | git daemon --verbose --export-all |
Junio C Hamano | 032c631 | 2006-09-28 07:39:18 | [diff] [blame] | 250 | --interpolated-path=/pub/%IP/%D |
| 251 | /pub/192.168.1.200/software |
| 252 | /pub/10.10.220.23/software |
| 253 | ------------------------------------------------ |
| 254 | + |
| 255 | In this example, the root-level directory `/pub` will contain |
| 256 | a subdirectory for each virtual host IP address supported. |
| 257 | Repositories can still be accessed by hostname though, assuming |
| 258 | they correspond to these IP addresses. |
| 259 | |
Junio C Hamano | dbb6459 | 2007-09-01 11:17:39 | [diff] [blame] | 260 | selectively enable/disable services per repository:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 261 | To enable 'git archive --remote' and disable 'git fetch' against |
Junio C Hamano | dbb6459 | 2007-09-01 11:17:39 | [diff] [blame] | 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'). |
Junio C Hamano | 21e7f9c | 2007-08-31 07:56:26 | [diff] [blame] | 265 | + |
| 266 | ---------------------------------------------------------------- |
Junio C Hamano | dbb6459 | 2007-09-01 11:17:39 | [diff] [blame] | 267 | [daemon] |
| 268 | uploadpack = false |
Junio C Hamano | feeb1be | 2008-05-22 00:53:35 | [diff] [blame] | 269 | uploadarch = true |
Junio C Hamano | 21e7f9c | 2007-08-31 07:56:26 | [diff] [blame] | 270 | ---------------------------------------------------------------- |
| 271 | |
| 272 | |
Junio C Hamano | 61b1229 | 2008-10-27 02:59:10 | [diff] [blame] | 273 | ENVIRONMENT |
| 274 | ----------- |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 275 | 'git daemon' will set REMOTE_ADDR to the IP address of the client |
Junio C Hamano | 61b1229 | 2008-10-27 02:59:10 | [diff] [blame] | 276 | that connected to it, if the IP address is available. REMOTE_ADDR will |
| 277 | be available in the environment of hooks called when |
| 278 | services are performed. |
| 279 | |
| 280 | |
| 281 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 282 | Author |
| 283 | ------ |
| 284 | Written by Linus Torvalds <torvalds@osdl.org>, YOSHIFUJI Hideaki |
| 285 | <yoshfuji@linux-ipv6.org> and the git-list <git@vger.kernel.org> |
| 286 | |
| 287 | Documentation |
| 288 | -------------- |
| 289 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. |
| 290 | |
| 291 | GIT |
| 292 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 293 | Part of the linkgit:git[1] suite |