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