{
    "content": [
        {
            "type": "text",
            "text": "# git-http-backend (info)\n\n## NAME\n\ngit-http-backend - Server side implementation of Git over HTTP\n\n## SYNOPSIS\n\ngit http-backend\n\n## DESCRIPTION\n\nA simple CGI program to serve the contents of a Git repository to Git\nclients accessing the repository over http:// and https:// protocols.\nThe program supports clients fetching using both the smart HTTP\nprotocol and the backwards-compatible dumb HTTP protocol, as well as\nclients pushing using the smart HTTP protocol. It also supports Git's\nmore-efficient \"v2\" protocol if properly configured; see the discussion\nof GITPROTOCOL in the ENVIRONMENT section below.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SERVICES**\n- **URL TRANSLATION**\n- **EXAMPLES**\n- **ENVIRONMENT**\n- **GIT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "git-http-backend",
        "section": "",
        "mode": "info",
        "summary": "git-http-backend - Server side implementation of Git over HTTP",
        "synopsis": "git http-backend",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "All of the following examples map http://$hostname/git/foo/bar.git to",
            "/var/www/git/foo/bar.git.",
            "Apache 2.x",
            "Ensure modcgi, modalias, and modenv are enabled, set",
            "GITPROJECTROOT (or DocumentRoot) appropriately, and create a",
            "ScriptAlias to the CGI:",
            "SetEnv GITPROJECTROOT /var/www/git",
            "SetEnv GITHTTPEXPORTALL",
            "ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/",
            "# This is not strictly necessary using Apache and a modern version of",
            "# git-http-backend, as the webserver will pass along the header in the",
            "# environment as HTTPGITPROTOCOL, and http-backend will copy that into",
            "# GITPROTOCOL. But you may need this line (or something similar if you",
            "# are using a different webserver), or if you want to support older Git",
            "# versions that did not do that copying.",
            "# Having the webserver set up GITPROTOCOL is perfectly fine even with",
            "# modern versions (and will take precedence over HTTPGITPROTOCOL,",
            "# which means it can be used to override the client's request).",
            "SetEnvIf Git-Protocol \".*\" GITPROTOCOL=$0",
            "To enable anonymous read access but authenticated write access,",
            "require authorization for both the initial ref advertisement (which",
            "we detect as a push via the service parameter in the query string),",
            "and the receive-pack invocation itself:",
            "RewriteCond %{QUERYSTRING} service=git-receive-pack [OR]",
            "RewriteCond %{REQUESTURI} /git-receive-pack$",
            "RewriteRule ^/git/ - [E=AUTHREQUIRED:yes]",
            "<LocationMatch \"^/git/\">",
            "Order Deny,Allow",
            "Deny from env=AUTHREQUIRED",
            "AuthType Basic",
            "AuthName \"Git Access\"",
            "Require group committers",
            "Satisfy Any",
            "...",
            "</LocationMatch>",
            "If you do not have modrewrite available to match against the query",
            "string, it is sufficient to just protect git-receive-pack itself,",
            "like:",
            "<LocationMatch \"^/git/.*/git-receive-pack$\">",
            "AuthType Basic",
            "AuthName \"Git Access\"",
            "Require group committers",
            "...",
            "</LocationMatch>",
            "In this mode, the server will not request authentication until the",
            "client actually starts the object negotiation phase of the push,",
            "rather than during the initial contact. For this reason, you must",
            "also enable the http.receivepack config option in any repositories",
            "that should accept a push. The default behavior, if",
            "http.receivepack is not set, is to reject any pushes by",
            "unauthenticated users; the initial request will therefore report",
            "403 Forbidden to the client, without even giving an opportunity for",
            "authentication.",
            "To require authentication for both reads and writes, use a Location",
            "directive around the repository, or one of its parent directories:",
            "<Location /git/private>",
            "AuthType Basic",
            "AuthName \"Private Git Access\"",
            "Require group committers",
            "...",
            "</Location>",
            "To serve gitweb at the same url, use a ScriptAliasMatch to only",
            "those URLs that git http-backend can handle, and forward the rest",
            "to gitweb:",
            "ScriptAliasMatch \\",
            "\"(?x)^/git/(.*/(HEAD | \\",
            "info/refs | \\",
            "objects/(info/[^/]+ | \\",
            "[0-9a-f]{2}/[0-9a-f]{38} | \\",
            "pack/pack-[0-9a-f]{40}\\.(pack|idx)) | \\",
            "git-(upload|receive)-pack))$\" \\",
            "/usr/libexec/git-core/git-http-backend/$1",
            "ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/",
            "To serve multiple repositories from different gitnamespaces(7) in a",
            "single repository:",
            "SetEnvIf RequestURI \"^/git/([^/]*)\" GITNAMESPACE=$1",
            "ScriptAliasMatch ^/git/[^/]*(.*) /usr/libexec/git-core/git-http-backend/storage.git$1",
            "Accelerated static Apache 2.x",
            "Similar to the above, but Apache can be used to return static files",
            "that are stored on disk. On many systems this may be more efficient",
            "as Apache can ask the kernel to copy the file contents from the",
            "file system directly to the network:",
            "SetEnv GITPROJECTROOT /var/www/git",
            "AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1",
            "AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1",
            "ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/",
            "This can be combined with the gitweb configuration:",
            "SetEnv GITPROJECTROOT /var/www/git",
            "AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1",
            "AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1",
            "ScriptAliasMatch \\",
            "\"(?x)^/git/(.*/(HEAD | \\",
            "info/refs | \\",
            "objects/info/[^/]+ | \\",
            "git-(upload|receive)-pack))$\" \\",
            "/usr/libexec/git-core/git-http-backend/$1",
            "ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/",
            "Lighttpd",
            "Ensure that modcgi, modalias, modauth, modsetenv are loaded,",
            "then set GITPROJECTROOT appropriately and redirect all requests",
            "to the CGI:",
            "alias.url += ( \"/git\" => \"/usr/lib/git-core/git-http-backend\" )",
            "$HTTP[\"url\"] =~ \"^/git\" {",
            "cgi.assign = (\"\" => \"\")",
            "setenv.add-environment = (",
            "\"GITPROJECTROOT\" => \"/var/www/git\",",
            "\"GITHTTPEXPORTALL\" => \"\"",
            "To enable anonymous read access but authenticated write access:",
            "$HTTP[\"querystring\"] =~ \"service=git-receive-pack\" {",
            "include \"git-auth.conf\"",
            "$HTTP[\"url\"] =~ \"^/git/.*/git-receive-pack$\" {",
            "include \"git-auth.conf\"",
            "where git-auth.conf looks something like:",
            "auth.require = (",
            "\"/\" => (",
            "\"method\" => \"basic\",",
            "\"realm\" => \"Git Access\",",
            "\"require\" => \"valid-user\"",
            "# ...and set up auth.backend here",
            "To require authentication for both reads and writes:",
            "$HTTP[\"url\"] =~ \"^/git/private\" {",
            "include \"git-auth.conf\""
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "SERVICES",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "URL TRANSLATION",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 162,
                "subsections": []
            },
            {
                "name": "ENVIRONMENT",
                "lines": 46,
                "subsections": []
            },
            {
                "name": "GIT",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "git-http-backend - Server side implementation of Git over HTTP\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "git http-backend\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "A simple CGI program to serve the contents of a Git repository to Git\nclients accessing the repository over http:// and https:// protocols.\nThe program supports clients fetching using both the smart HTTP\nprotocol and the backwards-compatible dumb HTTP protocol, as well as\nclients pushing using the smart HTTP protocol. It also supports Git's\nmore-efficient \"v2\" protocol if properly configured; see the discussion\nof GITPROTOCOL in the ENVIRONMENT section below.\n\nIt verifies that the directory has the magic file\n\"git-daemon-export-ok\", and it will refuse to export any Git directory\nthat hasn't explicitly been marked for export this way (unless the\nGITHTTPEXPORTALL environmental variable is set).\n\nBy default, only the upload-pack service is enabled, which serves git\nfetch-pack and git ls-remote clients, which are invoked from git fetch,\ngit pull, and git clone. If the client is authenticated, the\nreceive-pack service is enabled, which serves git send-pack clients,\nwhich is invoked from git push.\n",
                "subsections": []
            },
            "SERVICES": {
                "content": "These services can be enabled/disabled using the per-repository\nconfiguration file:\n\nhttp.getanyfile\nThis serves Git clients older than version 1.6.6 that are unable to\nuse the upload pack service. When enabled, clients are able to read\nany file within the repository, including objects that are no\nlonger reachable from a branch but are still present. It is enabled\nby default, but a repository can disable it by setting this\nconfiguration item to false.\n\nhttp.uploadpack\nThis serves git fetch-pack and git ls-remote clients. It is enabled\nby default, but a repository can disable it by setting this\nconfiguration item to false.\n\nhttp.receivepack\nThis serves git send-pack clients, allowing push. It is disabled by\ndefault for anonymous users, and enabled by default for users\nauthenticated by the web server. It can be disabled by setting this\nitem to false, or enabled for all users, including anonymous users,\nby setting it to true.\n",
                "subsections": []
            },
            "URL TRANSLATION": {
                "content": "To determine the location of the repository on disk, git http-backend\nconcatenates the environment variables PATHINFO, which is set\nautomatically by the web server, and GITPROJECTROOT, which must be\nset manually in the web server configuration. If GITPROJECTROOT is\nnot set, git http-backend reads PATHTRANSLATED, which is also set\nautomatically by the web server.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "All of the following examples map http://$hostname/git/foo/bar.git to\n/var/www/git/foo/bar.git.\n\nApache 2.x\nEnsure modcgi, modalias, and modenv are enabled, set\nGITPROJECTROOT (or DocumentRoot) appropriately, and create a\nScriptAlias to the CGI:\n\nSetEnv GITPROJECTROOT /var/www/git\nSetEnv GITHTTPEXPORTALL\nScriptAlias /git/ /usr/libexec/git-core/git-http-backend/\n\n# This is not strictly necessary using Apache and a modern version of\n# git-http-backend, as the webserver will pass along the header in the\n# environment as HTTPGITPROTOCOL, and http-backend will copy that into\n# GITPROTOCOL. But you may need this line (or something similar if you\n# are using a different webserver), or if you want to support older Git\n# versions that did not do that copying.\n#\n# Having the webserver set up GITPROTOCOL is perfectly fine even with\n# modern versions (and will take precedence over HTTPGITPROTOCOL,\n# which means it can be used to override the client's request).\nSetEnvIf Git-Protocol \".*\" GITPROTOCOL=$0\n\nTo enable anonymous read access but authenticated write access,\nrequire authorization for both the initial ref advertisement (which\nwe detect as a push via the service parameter in the query string),\nand the receive-pack invocation itself:\n\nRewriteCond %{QUERYSTRING} service=git-receive-pack [OR]\nRewriteCond %{REQUESTURI} /git-receive-pack$\nRewriteRule ^/git/ - [E=AUTHREQUIRED:yes]\n\n<LocationMatch \"^/git/\">\nOrder Deny,Allow\nDeny from env=AUTHREQUIRED\n\nAuthType Basic\nAuthName \"Git Access\"\nRequire group committers\nSatisfy Any\n...\n</LocationMatch>\n\nIf you do not have modrewrite available to match against the query\nstring, it is sufficient to just protect git-receive-pack itself,\nlike:\n\n<LocationMatch \"^/git/.*/git-receive-pack$\">\nAuthType Basic\nAuthName \"Git Access\"\nRequire group committers\n...\n</LocationMatch>\n\nIn this mode, the server will not request authentication until the\nclient actually starts the object negotiation phase of the push,\nrather than during the initial contact. For this reason, you must\nalso enable the http.receivepack config option in any repositories\nthat should accept a push. The default behavior, if\nhttp.receivepack is not set, is to reject any pushes by\nunauthenticated users; the initial request will therefore report\n403 Forbidden to the client, without even giving an opportunity for\nauthentication.\n\nTo require authentication for both reads and writes, use a Location\ndirective around the repository, or one of its parent directories:\n\n<Location /git/private>\nAuthType Basic\nAuthName \"Private Git Access\"\nRequire group committers\n...\n</Location>\n\nTo serve gitweb at the same url, use a ScriptAliasMatch to only\nthose URLs that git http-backend can handle, and forward the rest\nto gitweb:\n\nScriptAliasMatch \\\n\"(?x)^/git/(.*/(HEAD | \\\ninfo/refs | \\\nobjects/(info/[^/]+ | \\\n[0-9a-f]{2}/[0-9a-f]{38} | \\\npack/pack-[0-9a-f]{40}\\.(pack|idx)) | \\\ngit-(upload|receive)-pack))$\" \\\n/usr/libexec/git-core/git-http-backend/$1\n\nScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/\n\nTo serve multiple repositories from different gitnamespaces(7) in a\nsingle repository:\n\nSetEnvIf RequestURI \"^/git/([^/]*)\" GITNAMESPACE=$1\nScriptAliasMatch ^/git/[^/]*(.*) /usr/libexec/git-core/git-http-backend/storage.git$1\n\nAccelerated static Apache 2.x\nSimilar to the above, but Apache can be used to return static files\nthat are stored on disk. On many systems this may be more efficient\nas Apache can ask the kernel to copy the file contents from the\nfile system directly to the network:\n\nSetEnv GITPROJECTROOT /var/www/git\n\nAliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1\nAliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1\nScriptAlias /git/ /usr/libexec/git-core/git-http-backend/\n\nThis can be combined with the gitweb configuration:\n\nSetEnv GITPROJECTROOT /var/www/git\n\nAliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1\nAliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1\nScriptAliasMatch \\\n\"(?x)^/git/(.*/(HEAD | \\\ninfo/refs | \\\nobjects/info/[^/]+ | \\\ngit-(upload|receive)-pack))$\" \\\n/usr/libexec/git-core/git-http-backend/$1\nScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/\n\nLighttpd\nEnsure that modcgi, modalias, modauth, modsetenv are loaded,\nthen set GITPROJECTROOT appropriately and redirect all requests\nto the CGI:\n\nalias.url += ( \"/git\" => \"/usr/lib/git-core/git-http-backend\" )\n$HTTP[\"url\"] =~ \"^/git\" {\ncgi.assign = (\"\" => \"\")\nsetenv.add-environment = (\n\"GITPROJECTROOT\" => \"/var/www/git\",\n\"GITHTTPEXPORTALL\" => \"\"\n)\n}\n\nTo enable anonymous read access but authenticated write access:\n\n$HTTP[\"querystring\"] =~ \"service=git-receive-pack\" {\ninclude \"git-auth.conf\"\n}\n$HTTP[\"url\"] =~ \"^/git/.*/git-receive-pack$\" {\ninclude \"git-auth.conf\"\n}\n\nwhere git-auth.conf looks something like:\n\nauth.require = (\n\"/\" => (\n\"method\" => \"basic\",\n\"realm\" => \"Git Access\",\n\"require\" => \"valid-user\"\n)\n)\n# ...and set up auth.backend here\n\nTo require authentication for both reads and writes:\n\n$HTTP[\"url\"] =~ \"^/git/private\" {\ninclude \"git-auth.conf\"\n}\n",
                "subsections": []
            },
            "ENVIRONMENT": {
                "content": "git http-backend relies upon the CGI environment variables set by the\ninvoking web server, including:\n\no   PATHINFO (if GITPROJECTROOT is set, otherwise PATHTRANSLATED)\n\no   REMOTEUSER\n\no   REMOTEADDR\n\no   CONTENTTYPE\n\no   QUERYSTRING\n\no   REQUESTMETHOD\n\nThe GITHTTPEXPORTALL environmental variable may be passed to\ngit-http-backend to bypass the check for the \"git-daemon-export-ok\"\nfile in each repository before allowing export of that repository.\n\nThe GITHTTPMAXREQUESTBUFFER environment variable (or the\nhttp.maxRequestBuffer config variable) may be set to change the largest\nref negotiation request that git will handle during a fetch; any fetch\nrequiring a larger buffer will not succeed. This value should not\nnormally need to be changed, but may be helpful if you are fetching\nfrom a repository with an extremely large number of refs. The value can\nbe specified with a unit (e.g., 100M for 100 megabytes). The default is\n10 megabytes.\n\nClients may probe for optional protocol capabilities (like the v2\nprotocol) using the Git-Protocol HTTP header. In order to support\nthese, the contents of that header must appear in the GITPROTOCOL\nenvironment variable. Most webservers will pass this header to the CGI\nvia the HTTPGITPROTOCOL variable, and git-http-backend will\nautomatically copy that to GITPROTOCOL. However, some webservers may\nbe more selective about which headers they'll pass, in which case they\nneed to be configured explicitly (see the mention of Git-Protocol in\nthe Apache config from the earlier EXAMPLES section).\n\nThe backend process sets GITCOMMITTERNAME to $REMOTEUSER and\nGITCOMMITTEREMAIL to ${REMOTEUSER}@http.${REMOTEADDR}, ensuring\nthat any reflogs created by git-receive-pack contain some identifying\ninformation of the remote user who performed the push.\n\nAll CGI environment variables are available to each of the hooks\ninvoked by the git-receive-pack.\n",
                "subsections": []
            },
            "GIT": {
                "content": "Part of the git(1) suite\n\nGit 2.34.1                        02/26/2026               GIT-HTTP-BACKEND(1)",
                "subsections": []
            }
        }
    }
}