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