Documentation / git-http-backend.txton commit Merge branch 'maint-1.6.5' into maint (f0b0d78)
   1git-http-backend(1)
   2===================
   3
   4NAME
   5----
   6git-http-backend - Server side implementation of Git over HTTP
   7
   8SYNOPSIS
   9--------
  10[verse]
  11'git-http-backend'
  12
  13DESCRIPTION
  14-----------
  15A simple CGI program to serve the contents of a Git repository to Git
  16clients accessing the repository over http:// and https:// protocols.
  17The program supports clients fetching using both the smart HTTP protcol
  18and the backwards-compatible dumb HTTP protocol, as well as clients
  19pushing using the smart HTTP protocol.
  20
  21By default, only the `upload-pack` service is enabled, which serves
  22'git-fetch-pack' and 'git-ls-remote' clients, which are invoked from
  23'git-fetch', 'git-pull', and 'git-clone'.  If the client is authenticated,
  24the `receive-pack` service is enabled, which serves 'git-send-pack'
  25clients, which is invoked from 'git-push'.
  26
  27SERVICES
  28--------
  29These services can be enabled/disabled using the per-repository
  30configuration file:
  31
  32http.getanyfile::
  33        This serves older Git clients which are unable to use the
  34        upload pack service.  When enabled, clients are able to read
  35        any file within the repository, including objects that are
  36        no longer reachable from a branch but are still present.
  37        It is enabled by default, but a repository can disable it
  38        by setting this configuration item to `false`.
  39
  40http.uploadpack::
  41        This serves 'git-fetch-pack' and 'git-ls-remote' clients.
  42        It is enabled by default, but a repository can disable it
  43        by setting this configuration item to `false`.
  44
  45http.receivepack::
  46        This serves 'git-send-pack' clients, allowing push.  It is
  47        disabled by default for anonymous users, and enabled by
  48        default for users authenticated by the web server.  It can be
  49        disabled by setting this item to `false`, or enabled for all
  50        users, including anonymous users, by setting it to `true`.
  51
  52URL TRANSLATION
  53---------------
  54To determine the location of the repository on disk, 'git-http-backend'
  55concatenates the environment variables PATH_INFO, which is set
  56automatically by the web server, and GIT_PROJECT_ROOT, which must be set
  57manually in the web server configuration.  If GIT_PROJECT_ROOT is not
  58set, 'git-http-backend' reads PATH_TRANSLATED, which is also set
  59automatically by the web server.
  60
  61EXAMPLES
  62--------
  63All of the following examples map 'http://$hostname/git/foo/bar.git'
  64to '/var/www/git/foo/bar.git'.
  65
  66Apache 2.x::
  67        Ensure mod_cgi, mod_alias, and mod_env are enabled, set
  68        GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and
  69        create a ScriptAlias to the CGI:
  70+
  71----------------------------------------------------------------
  72SetEnv GIT_PROJECT_ROOT /var/www/git
  73ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
  74----------------------------------------------------------------
  75+
  76To enable anonymous read access but authenticated write access,
  77require authorization with a LocationMatch directive:
  78+
  79----------------------------------------------------------------
  80<LocationMatch "^/git/.*/git-receive-pack$">
  81        AuthType Basic
  82        AuthName "Git Access"
  83        Require group committers
  84        ...
  85</LocationMatch>
  86----------------------------------------------------------------
  87+
  88To require authentication for both reads and writes, use a Location
  89directive around the repository, or one of its parent directories:
  90+
  91----------------------------------------------------------------
  92<Location /git/private>
  93        AuthType Basic
  94        AuthName "Private Git Access"
  95        Require group committers
  96        ...
  97</Location>
  98----------------------------------------------------------------
  99+
 100To serve gitweb at the same url, use a ScriptAliasMatch to only
 101those URLs that 'git-http-backend' can handle, and forward the
 102rest to gitweb:
 103+
 104----------------------------------------------------------------
 105ScriptAliasMatch \
 106        "(?x)^/git/(.*/(HEAD | \
 107                        info/refs | \
 108                        objects/(info/[^/]+ | \
 109                                 [0-9a-f]{2}/[0-9a-f]{38} | \
 110                                 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
 111                        git-(upload|receive)-pack))$" \
 112        /usr/libexec/git-core/git-http-backend/$1
 113
 114ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 115----------------------------------------------------------------
 116
 117Accelerated static Apache 2.x::
 118        Similar to the above, but Apache can be used to return static
 119        files that are stored on disk.  On many systems this may
 120        be more efficient as Apache can ask the kernel to copy the
 121        file contents from the file system directly to the network:
 122+
 123----------------------------------------------------------------
 124SetEnv GIT_PROJECT_ROOT /var/www/git
 125
 126AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1
 127AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
 128ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
 129----------------------------------------------------------------
 130+
 131This can be combined with the gitweb configuration:
 132+
 133----------------------------------------------------------------
 134SetEnv GIT_PROJECT_ROOT /var/www/git
 135
 136AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1
 137AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
 138ScriptAliasMatch \
 139        "(?x)^/git/(.*/(HEAD | \
 140                        info/refs | \
 141                        objects/info/[^/]+ | \
 142                        git-(upload|receive)-pack))$" \
 143        /usr/libexec/git-core/git-http-backend/$1
 144ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 145----------------------------------------------------------------
 146
 147
 148ENVIRONMENT
 149-----------
 150'git-http-backend' relies upon the CGI environment variables set
 151by the invoking web server, including:
 152
 153* PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)
 154* REMOTE_USER
 155* REMOTE_ADDR
 156* CONTENT_TYPE
 157* QUERY_STRING
 158* REQUEST_METHOD
 159
 160The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and
 161GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
 162ensuring that any reflogs created by 'git-receive-pack' contain some
 163identifying information of the remote user who performed the push.
 164
 165All CGI environment variables are available to each of the hooks
 166invoked by the 'git-receive-pack'.
 167
 168Author
 169------
 170Written by Shawn O. Pearce <spearce@spearce.org>.
 171
 172Documentation
 173--------------
 174Documentation by Shawn O. Pearce <spearce@spearce.org>.
 175
 176GIT
 177---
 178Part of the linkgit:git[1] suite