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, the offers are limited to repositories within
34       those directories.
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 directory arguments are provided.
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 list.
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, a request 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           The remaining arguments provide a list of directories. If any
205           directories are specified, then the git-daemon process will serve a
206           requested directory only if it is contained in one of these
207           directories. If --strict-paths is specified, then the requested
208           directory must match one of these directories exactly.
209

SERVICES

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

EXAMPLES

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

ENVIRONMENT

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

GIT

301       Part of the git(1) suite
302
303
304
305Git 2.43.0                        11/20/2023                     GIT-DAEMON(1)
Impressum