1GIT-DAEMON(1)                     Git Manual                     GIT-DAEMON(1)
2
3
4

NAME

6       git-daemon - A really simple server for Git repositories
7

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

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 (may be
81           overridden with --log-destination=). Incompatible with --detach,
82           --port, --listen, --user and --group 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           Short for --log-destination=syslog.
111
112       --log-destination=<destination>
113           Send log messages to the specified destination. Note that this
114           option does not imply --verbose, thus by default only error
115           conditions will be logged. The <destination> must be one of:
116
117           stderr
118               Write to standard error. Note that if --detach is specified,
119               the process disconnects from the real standard error, making
120               this destination effectively equivalent to none.
121
122           syslog
123               Write to syslog, using the git-daemon identifier.
124
125           none
126               Disable all logging.
127
128           The default destination is syslog if --inetd or --detach is
129           specified, otherwise stderr.
130
131       --user-path, --user-path=<path>
132           Allow ~user notation to be used in requests. When specified with no
133           parameter, requests to git://host/~alice/foo is taken as a request
134           to access foo repository in the home directory of user alice. If
135           --user-path=path is specified, the same request is taken as a
136           request to access path/foo repository in the home directory of user
137           alice.
138
139       --verbose
140           Log details about the incoming connections and requested files.
141
142       --reuseaddr
143           Use SO_REUSEADDR when binding the listening socket. This allows the
144           server to restart without waiting for old connections to time out.
145
146       --detach
147           Detach from the shell. Implies --syslog.
148
149       --pid-file=<file>
150           Save the process id in file. Ignored when the daemon is run under
151           --inetd.
152
153       --user=<user>, --group=<group>
154           Change daemon’s uid and gid before entering the service loop. When
155           only --user is given without --group, the primary group ID for the
156           user is used. The values of the option are given to getpwnam(3) and
157           getgrnam(3) and numeric IDs are not supported.
158
159           Giving these options is an error when used with --inetd; use the
160           facility of inet daemon to achieve the same before spawning git
161           daemon if needed.
162
163           Like many programs that switch user id, the daemon does not reset
164           environment variables such as $HOME when it runs git programs, e.g.
165           upload-pack and receive-pack. When using this option, you may also
166           want to set and export HOME to point at the home directory of
167           <user> before starting the daemon, and make sure any Git
168           configuration files in that directory are readable by <user>.
169
170       --enable=<service>, --disable=<service>
171           Enable/disable the service site-wide per default. Note that a
172           service disabled site-wide can still be enabled per repository if
173           it is marked overridable and the repository enables the service
174           with a configuration item.
175
176       --allow-override=<service>, --forbid-override=<service>
177           Allow/forbid overriding the site-wide default with per repository
178           configuration. By default, all the services may be overridden.
179
180       --[no-]informative-errors
181           When informative errors are turned on, git-daemon will report more
182           verbose errors to the client, differentiating conditions like "no
183           such repository" from "repository not exported". This is more
184           convenient for clients, but may leak information about the
185           existence of unexported repositories. When informative errors are
186           not enabled, all errors report "access denied" to the client. The
187           default is --no-informative-errors.
188
189       --access-hook=<path>
190           Every time a client connects, first run an external command
191           specified by the <path> with service name (e.g. "upload-pack"),
192           path to the repository, hostname (%H), canonical hostname (%CH), IP
193           address (%IP), and TCP port (%P) as its command-line arguments. The
194           external command can decide to decline the service by exiting with
195           a non-zero status (or to allow it by exiting with a zero status).
196           It can also look at the $REMOTE_ADDR and $REMOTE_PORT environment
197           variables to learn about the requestor when making this decision.
198
199           The external command can optionally write a single line to its
200           standard output to be sent to the requestor as an error message
201           when it declines the service.
202
203       <directory>
204           A directory to add to the whitelist of allowed directories. Unless
205           --strict-paths is specified this will also include subdirectories
206           of each named directory.
207

SERVICES

209       These services can be globally enabled/disabled using the command-line
210       options of this command. If finer-grained control is desired (e.g. to
211       allow git archive to be run against only in a few selected repositories
212       the daemon serves), the per-repository configuration file can be used
213       to enable or disable them.
214
215       upload-pack
216           This serves git fetch-pack and git ls-remote clients. It is enabled
217           by default, but a repository can disable it by setting
218           daemon.uploadpack configuration item to false.
219
220       upload-archive
221           This serves git archive --remote. It is disabled by default, but a
222           repository can enable it by setting daemon.uploadarch configuration
223           item to true.
224
225       receive-pack
226           This serves git send-pack clients, allowing anonymous push. It is
227           disabled by default, as there is no authentication in the protocol
228           (in other words, anybody can push anything into the repository,
229           including removal of refs). This is solely meant for a closed LAN
230           setting where everybody is friendly. This service can be enabled by
231           setting daemon.receivepack configuration item to true.
232

EXAMPLES

234       We assume the following in /etc/services
235
236               $ grep 9418 /etc/services
237               git             9418/tcp                # Git Version Control System
238
239       git daemon as inetd server
240           To set up git daemon as an inetd service that handles any
241           repository under the whitelisted set of directories, /pub/foo and
242           /pub/bar, place an entry like the following into /etc/inetd all on
243           one line:
244
245                       git stream tcp nowait nobody  /usr/bin/git
246                               git daemon --inetd --verbose --export-all
247                               /pub/foo /pub/bar
248
249       git daemon as inetd server for virtual hosts
250           To set up git daemon as an inetd service that handles repositories
251           for different virtual hosts, www.example.com and www.example.org,
252           place an entry like the following into /etc/inetd all on one line:
253
254                       git stream tcp nowait nobody /usr/bin/git
255                               git daemon --inetd --verbose --export-all
256                               --interpolated-path=/pub/%H%D
257                               /pub/www.example.org/software
258                               /pub/www.example.com/software
259                               /software
260
261           In this example, the root-level directory /pub will contain a
262           subdirectory for each virtual host name supported. Further, both
263           hosts advertise repositories simply as
264           git://www.example.com/software/repo.git. For pre-1.4.0 clients, a
265           symlink from /software into the appropriate default repository
266           could be made as well.
267
268       git daemon as regular daemon for virtual hosts
269           To set up git daemon as a regular, non-inetd service that handles
270           repositories for multiple virtual hosts based on their IP
271           addresses, start the daemon like this:
272
273                       git daemon --verbose --export-all
274                               --interpolated-path=/pub/%IP/%D
275                               /pub/192.168.1.200/software
276                               /pub/10.10.220.23/software
277
278           In this example, the root-level directory /pub will contain a
279           subdirectory for each virtual host IP address supported.
280           Repositories can still be accessed by hostname though, assuming
281           they correspond to these IP addresses.
282
283       selectively enable/disable services per repository
284           To enable git archive --remote and disable git fetch against a
285           repository, have the following in the configuration file in the
286           repository (that is the file config next to HEAD, refs and
287           objects).
288
289                       [daemon]
290                               uploadpack = false
291                               uploadarch = true
292

ENVIRONMENT

294       git daemon will set REMOTE_ADDR to the IP address of the client that
295       connected to it, if the IP address is available. REMOTE_ADDR will be
296       available in the environment of hooks called when services are
297       performed.
298

GIT

300       Part of the git(1) suite
301
302
303
304Git 2.30.2                        2021-03-08                     GIT-DAEMON(1)
Impressum