The complement to fetch-pack.
git upload-pack is the server side of fetch and clone. It listens to a client's fetch-pack, negotiates which objects are wanted vs already had, and streams back a packfile containing exactly the missing objects.
Two processes playing 20-questions across a pipe: client sends want <oid> lines, server replies with have/ACK rounds, then ships a single packfile. Lives behind ssh://, git://, and http:// (via git-http-backend).
git upload-pack [--strict] [--timeout=<n>] [--stateless-rpc]
[--advertise-refs] [--http-backend-info-refs]
[--no-done] <directory>
# Typical invocation by sshd
git-upload-pack '/srv/git/repo.git'
# Smart-HTTP info/refs phase
git-upload-pack --stateless-rpc --advertise-refs <dir>| Flag | What it does |
|---|---|
--strict | Require <directory> to be a real Git dir; don't try .git suffix fallbacks |
--timeout=<n> | Seconds to wait on the client before giving up; useful behind flaky networks |
--stateless-rpc | Speak the smart-HTTP single-shot RPC dialect instead of long-lived SSH/git-protocol |
--advertise-refs | Only emit the initial ref advertisement and exit (HTTP info/refs phase) |
--http-backend-info-refs | Alias of --advertise-refs used by git-http-backend |
--no-done | Allow the v0/v1 negotiation to skip the final done round-trip (latency win) |
git-http-backend--timeout tunedgit clone git@host:repo.gitgit-upload-pack '/srv/git/repo.git'git upload-pack --advertise-refs /srv/git/repo.gitgit upload-pack --stateless-rpc --http-backend-info-refs /srv/git/repo.gitGIT_PROTOCOL=version=2 git -c uploadpack.timeout=30 upload-pack /srv/git/repo.gituploadpack.allowFilter=true, protocol.version=2) — partial clone and ref filtering only work thereuploadpack.allowReachableSHA1InWant cautiously: it lets clients fetch any reachable commit by SHA, which leaks history shape--strict in production to avoid surprising path coercionupload-pack (server sends to client during fetch) with receive-pack (server receives from client during push) — names describe the server's role--timeout too low and breaking large clones over slow links--advertise-refs then a stateless POSTHit each option, then Check answers. Score is recorded; Next is always open.