table of contents
GIT-DAEMON(1) | Git Manual | GIT-DAEMON(1) |
NAME¶
git-daemon - A really simple server for Git repositories
SYNOPSIS¶
git daemon [--verbose] [--syslog] [--export-all]
[--timeout=<n>] [--init-timeout=<n>] [--max-connections=<n>]
[--strict-paths] [--base-path=<path>] [--base-path-relaxed]
[--user-path | --user-path=<path>]
[--interpolated-path=<pathtemplate>]
[--reuseaddr] [--detach] [--pid-file=<file>]
[--enable=<service>] [--disable=<service>]
[--allow-override=<service>] [--forbid-override=<service>]
[--access-hook=<path>] [--[no-]informative-errors]
[--inetd |
[--listen=<host_or_ipaddr>] [--port=<n>]
[--user=<user> [--group=<group>]]]
[--log-destination=(stderr|syslog|none)]
[<directory>...]
DESCRIPTION¶
A really simple TCP Git daemon that normally listens on port "DEFAULT_GIT_PORT" aka 9418. It waits for a connection asking for a service, and will serve that service if it is enabled.
It verifies that the directory has the magic file "git-daemon-export-ok", and it will refuse to export any Git directory that hasn’t explicitly been marked for export this way (unless the --export-all parameter is specified). If you pass some directory paths as git daemon arguments, the offers are limited to repositories within those directories.
By default, only upload-pack service is enabled, which serves git fetch-pack and git ls-remote clients, which are invoked from git fetch, git pull, and git clone.
This is ideally suited for read-only updates, i.e., pulling from Git repositories.
An upload-archive also exists to serve git archive.
OPTIONS¶
--strict-paths
--base-path=<path>
--base-path-relaxed
--interpolated-path=<pathtemplate>
--export-all
--inetd
--listen=<host_or_ipaddr>
--port=<n>
--init-timeout=<n>
--timeout=<n>
--max-connections=<n>
--syslog
--log-destination=<destination>
stderr
syslog
none
The default destination is syslog if --inetd or --detach is specified, otherwise stderr.
--user-path, --user-path=<path>
--verbose
--reuseaddr
--detach
--pid-file=<file>
--user=<user>, --group=<group>
Giving these options is an error when used with --inetd; use the facility of inet daemon to achieve the same before spawning git daemon if needed.
Like many programs that switch user id, the daemon does not reset environment variables such as $HOME when it runs git programs, e.g. upload-pack and receive-pack. When using this option, you may also want to set and export HOME to point at the home directory of <user> before starting the daemon, and make sure any Git configuration files in that directory are readable by <user>.
--enable=<service>, --disable=<service>
--allow-override=<service>, --forbid-override=<service>
--[no-]informative-errors
--access-hook=<path>
The external command can optionally write a single line to its standard output to be sent to the requestor as an error message when it declines the service.
<directory>
SERVICES¶
These services can be globally enabled/disabled using the command-line options of this command. If finer-grained control is desired (e.g. to allow git archive to be run against only in a few selected repositories the daemon serves), the per-repository configuration file can be used to enable or disable them.
upload-pack
upload-archive
receive-pack
EXAMPLES¶
We assume the following in /etc/services
$ grep 9418 /etc/services git 9418/tcp # Git Version Control System
git daemon as inetd server
git stream tcp nowait nobody /usr/bin/git
git daemon --inetd --verbose --export-all
/pub/foo /pub/bar
git daemon as inetd server for virtual hosts
git stream tcp nowait nobody /usr/bin/git
git daemon --inetd --verbose --export-all
--interpolated-path=/pub/%H%D
/pub/www.example.org/software
/pub/www.example.com/software
/software
In this example, the root-level directory /pub will contain a subdirectory for each virtual host name supported. Further, both hosts advertise repositories simply as git://www.example.com/software/repo.git. For pre-1.4.0 clients, a symlink from /software into the appropriate default repository could be made as well.
git daemon as regular daemon for virtual hosts
git daemon --verbose --export-all
--interpolated-path=/pub/%IP/%D
/pub/192.168.1.200/software
/pub/10.10.220.23/software
In this example, the root-level directory /pub will contain a subdirectory for each virtual host IP address supported. Repositories can still be accessed by hostname though, assuming they correspond to these IP addresses.
selectively enable/disable services per repository
[daemon]
uploadpack = false
uploadarch = true
ENVIRONMENT¶
git daemon will set REMOTE_ADDR to the IP address of the client that connected to it, if the IP address is available. REMOTE_ADDR will be available in the environment of hooks called when services are performed.
GIT¶
Part of the git(1) suite
11/20/2023 | Git 2.43.0 |