Skip to content

http-fetch Git Command Guide

The git http-fetch protocol implements client-side HTTP fetching for retrieving Git objects and references from remote repositories served over HTTP/HTTPS.

  • Reference Discovery: Retrieve remote repository references via HTTP
  • Efficient Transfer: Use smart HTTP protocol for optimized object fetching
  • Authentication Support: Handle HTTP authentication and TLS certificates
  • Incremental Updates: Support for shallow cloning and partial fetching
  • Protocol Negotiation: Compatible with Git’s smart HTTPBackend servers
GET /repo.git/info/refs?service=git-upload-pack # Smart protocol
GET /repo.git/HEAD # Default branch
GET /repo.git/info/refs # Reference listing
POST /repo.git/git-upload-pack # Upload pack negotiation
# Binary pack data transfer follows acknowledgment
Terminal window
git config credential.helper store
git config http.sslVerify true
git config http.postBuffer 524288000 # 500MB for large transfers
Terminal window
git config http.proxy http://proxy.example.com:8080
git config https.proxy https://secure-proxy.example.com:8080
Terminal window
git config http.sslCAInfo /path/to/ca-bundle.crt
git config http.sslCAPath /etc/ssl/certs/
git config http.sslCert /path/to/client-cert.pem
Terminal window
# Check stored credentials
git config --list | grep credential
# Manual credential entry
git credential fill << EOF
protocol=https
host=github.com
EOF
Terminal window
# Disable SSL verification (not recommended)
git config http.sslVerify false
# Add custom CA certificate
git config http.sslCAInfo /path/to/ca-cert.pem
Terminal window
git clone https://github.com/user/repo.git

Standard clone operation using HTTP fetch protocol.

Terminal window
git fetch origin

Retrieve latest changes using HTTP protocol.

Terminal window
git clone --depth 1 https://github.com/user/repo.git

Limit history for faster initial fetch.

Terminal window
git clone https://username@github.com/user/repo.git

Fetch repository with username in URL.

Terminal window
git fetch origin feature-branch:local-branch

Retrieve specific remote branch to local.

Terminal window
GIT_HTTP_BUFFER=524288000 git fetch origin

Increase buffer size for large repository fetches.

Terminal window
git -c http.proxy=http://proxy.example.com:8080 fetch origin

Fetch through HTTP proxy server.

Terminal window
GIT_CURL_VERBOSE=1 git fetch origin 2>&1 | head -50

Enable verbose HTTP debugging output.

HTTP uses regular web ports (80/443) while SSH uses port 22. HTTP can cache at network level but typically slower due to protocol overhead.

Why would HTTP fetch fail while SSH succeeds?

Section titled “Why would HTTP fetch fail while SSH succeeds?”

Common causes: corporate proxies blocking Git protocol, authentication token expiry, SSL certificate trust issues, or server-side rate limiting.

Optimized Git transfer over HTTP that uses Git’s native pack protocol instead of downloading individual files. Significantly faster than dumb HTTP.

Use git config http.sslCAInfo to specify custom CA certificate, or disable verification with http.sslVerify false (not recommended for production).

Partial pack file downloads cannot be resumed. Use git fetch —force to restart. For large repositories, consider shallow clones first.

What’s the impact of proxy on fetch performance?

Section titled “What’s the impact of proxy on fetch performance?”

Proxies add latency and may cache stale responses. HTTP caching works poorly for Git’s dynamic fetch requests. SSH typically faster through proxies.

Set GIT_CURL_VERBOSE=1 for detailed connection logs, check firewall/proxy policies, verify SSL certificates, and test direct HTTP access to repository.

  1. Firewall Traversal: Access repositories through corporate firewalls that block SSH
  2. Public Repository Access: Standard method for cloning public Git repositories
  3. CDN Compatibility: Leverage web infrastructure for distributed repository serving
  4. Enterprise Environments: HTTP access through proxy servers and authenticated tunnels
  5. Continuous Integration: Automated fetching in CI/CD pipelines behind corporate networks
  6. Bandwidth Optimization: Smart HTTP’s efficient pack-based transfer for large repositories