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