http-backend Git Command Guide
The git http-backend command is a CGI program that serves Git repository content over HTTP and HTTPS protocols, enabling web-based Git hosting and remote access.
git http-backend Features:
Section titled “git http-backend Features:”- Smart HTTP Protocol: Supports efficient Git transfer over HTTP
- Backward Compatibility: Fallback to dumb HTTP for older clients
- Security Control: Repository access verification via file markers
- Protocol Support: Handles fetch, push, and repository discovery
Configuration Requirements:
Section titled “Configuration Requirements:”CGI Setup:
Section titled “CGI Setup:”<VirtualHost *:80> ServerName git.example.com DocumentRoot /var/www/git
ScriptAlias / /usr/lib/git-core/git-http-backend/ <Directory "/usr/lib/git-core"> Options ExecCGI AllowOverride None Require all granted </Directory>
Alias /static /usr/share/gitweb/static <Directory "/usr/share/gitweb/static"> AllowOverride None Require all granted </Directory></Directory>Repository Export:
Section titled “Repository Export:”# Mark repository for exporttouch /path/to/repo.git/git-daemon-export-ok
# Or export all repos (less secure)export GIT_HTTP_EXPORT_ALL=1Authentication:
Section titled “Authentication:”AuthType BasicAuthName "Git Access"AuthUserFile /etc/git-usersRequire valid-userSecurity Features:
Section titled “Security Features:”Access Control:
Section titled “Access Control:”| Method | Description |
|---|---|
| GIT_HTTP_EXPORT_ALL | Export all accessible repositories |
| git-daemon-export-ok | Mark specific repositories for export |
| Web Server Auth | HTTP authentication for access control |
| HTTPS Required | SSL/TLS encryption for security |
Protocol Limitations:
Section titled “Protocol Limitations:”- No anonymous access to sensitive repositories
- Requires web server configuration and permissions
- File system permissions must allow web server access
git http-backend Command Samples:
Section titled “git http-backend Command Samples:”Basic repository access test
Section titled “Basic repository access test”curl -u user:password https://git.example.com/repo.git/info/refsTest authenticated repository access via HTTP.
Push with smart HTTP
Section titled “Push with smart HTTP”git push https://user@git.example.com/repo.git masterPush commits using smart HTTP protocol for efficiency.
Clone via HTTP backend
Section titled “Clone via HTTP backend”git clone https://git.example.com/repo.gitClone repository using HTTP backend serving.
Web server integration test
Section titled “Web server integration test”GET https://git.example.com/repo.git/HEADVerify web server correctly routes to git-http-backend CGI.
Large repository serving
Section titled “Large repository serving”curl -I https://git.example.com/large-repo.git/info/refsCheck headers for large repository HTTP serving capability.
How do I configure Apache for git-http-backend?
Section titled “How do I configure Apache for git-http-backend?”Set up ScriptAlias to point to git-http-backend binary, configure CGI execution permissions, and set up authentication as needed.
What’s the difference between smart and dumb HTTP?
Section titled “What’s the difference between smart and dumb HTTP?”Smart HTTP uses efficient binary transfer protocols like Git’s native protocol. Dumb HTTP downloads repository files individually, much slower for large repos.
Can git-http-backend serve read-only repositories?
Section titled “Can git-http-backend serve read-only repositories?”Yes, by default only upload-pack (read/fetch) service is enabled. Add authentication to enable receive-pack (push) service.
How does authentication work with git-http-backend?
Section titled “How does authentication work with git-http-backend?”Authentication is handled by the web server (Apache/Nginx), not Git. Git receives authenticated user context for hook execution.
What’s required for push operations over HTTP?
Section titled “What’s required for push operations over HTTP?”receive-pack service must be enabled (requires authentication) and repository must be writable by web server user.
Can git-http-backend handle Git LFS?
Section titled “Can git-http-backend handle Git LFS?”Git LFS works over HTTP backends same as other Git operations - LFS pointers are handled by client, not server.
How do I troubleshoot git-http-backend issues?
Section titled “How do I troubleshoot git-http-backend issues?”Check CGI execution permissions, repository access rights, web server logs, and git-http-backend direct command execution.
What’s the performance impact of HTTP vs SSH?
Section titled “What’s the performance impact of HTTP vs SSH?”HTTP can be slower due to protocol overhead but provides better firewall traversal. Performance depends on server configuration and network.
Applications of the http-backend command
Section titled “Applications of the http-backend command”- Web Hosting: Serve Git repositories through web servers like Apache/Nginx
- Firewall Friendly: Access repositories over HTTP/S when SSH is blocked
- CDN Compatible: Potential for HTTP caching and CDN acceleration of Git operations
- Browser Access: Enable web-based Git repository browsing and cloning
- Enterprise Deployment: Large-scale Git repository hosting in corporate environments
- Cloud Integration: Support Git operations in cloud web application platforms