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