Smart fetch and push over HTTP: server side
[git/mingw.git] / Documentation / git-http-backend.txt
blob022a2433a86a1939435b5d76a95daf39ff0a32e1
1 git-http-backend(1)
2 ===================
4 NAME
5 ----
6 git-http-backend - Server side implementation of Git over HTTP
8 SYNOPSIS
9 --------
10 [verse]
11 'git-http-backend'
13 DESCRIPTION
14 -----------
15 A simple CGI program to serve the contents of a Git repository to Git
16 clients accessing the repository over http:// and https:// protocols.
18 By default, only the `upload-pack` service is enabled, which serves
19 'git-fetch-pack' and 'git-ls-remote' clients, which are invoked from
20 'git-fetch', 'git-pull', and 'git-clone'.
22 This is ideally suited for read-only updates, i.e., pulling from
23 git repositories.
25 SERVICES
26 --------
27 These services can be enabled/disabled using the per-repository
28 configuration file:
30 http.uploadpack::
31         This serves 'git-fetch-pack' and 'git-ls-remote' clients.
32         It is enabled by default, but a repository can disable it
33         by setting this configuration item to `false`.
35 http.receivepack::
36         This serves 'git-send-pack' clients, allowing push.  It is
37         disabled by default for anonymous users, and enabled by
38         default for users authenticated by the web server.  It can be
39         disabled by setting this item to `false`, or enabled for all
40         users, including anonymous users, by setting it to `true`.
42 URL TRANSLATION
43 ---------------
44 'git-http-backend' relies on the invoking web server to perform
45 URL to path translation, and store the repository path into the
46 PATH_TRANSLATED environment variable.  Most web servers will do
47 this translation automatically, resolving the suffix after the
48 CGI name relative to the server's document root.
50 EXAMPLES
51 --------
53 Apache 2.x::
54         To serve all Git repositories contained within the '/git/'
55         subdirectory of the DocumentRoot, ensure mod_cgi and
56         mod_alias are enabled, and create a ScriptAlias to the CGI:
58 ----------------------------------------------------------------
59 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/git/
61 <Directory /usr/libexec/git-core>
62         Options None
63 </Directory>
64 <Files /usr/libexec/git-core/git-http-backend>
65         Options ExecCGI
66 </Files>
67 ----------------------------------------------------------------
69 To enable anonymous read access but authenticated write access,
70 require authorization with a LocationMatch directive:
72 ----------------------------------------------------------------
73 <LocationMatch ".*/git-receive-pack$">
74         AuthType Basic
75         AuthName "Git Access"
76         Require group committers
77         ...
78 </LocationMatch>
79 ----------------------------------------------------------------
81 To require authentication for both reads and writes, use a Directory
82 directive around the repository, or one of its parent directories:
84 ----------------------------------------------------------------
85 <Directory /var/www/git/private>
86         AuthType Basic
87         AuthName "Private Git Access"
88         Require group committers
89         ...
90 </Directory>
91 ----------------------------------------------------------------
93 Accelerated static Apache 2.x::
94         Similar to the above, but Apache can be used to return static
95         files that are stored on disk.  On many systems this may
96         be more efficient as Apache can ask the kernel to copy the
97         file contents from the file system directly to the network:
99 ----------------------------------------------------------------
100 DocumentRoot /var/www
102 ScriptAlias /git/        /usr/libexec/git-core/git-http-backend/git/
103 Alias       /git_static/ /var/www/git/
105 RewriteEngine on
106 RewriteRule ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$    /git_static/$1 [PT]
107 RewriteRule ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.pack)$ /git_static/$1 [PT]
108 RewriteRule ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.idx)$  /git_static/$1 [PT]
109 ----------------------------------------------------------------
112 ENVIRONMENT
113 -----------
114 'git-http-backend' relies upon the CGI environment variables set
115 by the invoking web server, including:
117 * PATH_TRANSLATED
118 * REMOTE_USER
119 * REMOTE_ADDR
120 * CONTENT_TYPE
121 * QUERY_STRING
122 * REQUEST_METHOD
124 The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and
125 GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
126 ensuring that any reflogs created by 'git-receive-pack' contain some
127 identifying information of the remote user who performed the push.
129 All CGI environment variables are available to each of the hooks
130 invoked by the 'git-receive-pack'.
132 Author
133 ------
134 Written by Shawn O. Pearce <spearce@spearce.org>.
136 Documentation
137 --------------
138 Documentation by Shawn O. Pearce <spearce@spearce.org>.
142 Part of the linkgit:git[1] suite