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