Progress:
TIER 3 · MODULE 46· Expert

git fetch-pack

What 'fetch' invokes to negotiate and receive packs.

🎯 What & why

git fetch-pack is the client half of object exchange — it talks to a remote upload-pack, negotiates which objects you have versus what you want, and writes the resulting pack into your object store.

🧠 Mental model

Picture a 'have/want' conversation: client lists wants (refs to fetch), then offers haves (commits it already owns); the server walks back until it finds common ancestors and ships only the missing closure as a thin or thick pack.

🛠️ Synopsis

git fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin]
               [--include-tag] [--upload-pack=<git-upload-pack>]
               [--depth=<n>] [--shallow-since=<date>]
               [--shallow-exclude=<ref>] [--deepen-relative]
               [--no-progress] [--check-self-contained-and-connected]
               [--cloning] [-v] <repository> [<refs>...]

🎚️ Switches & options

FlagWhat it does
--allFetch every ref the remote advertises
--quietSuppress non-error output to stderr
--keepKeep the downloaded pack rather than letting it be exploded into loose objects
--thinRequest a thin pack — smaller wire size, fattened locally
--include-tagPull annotated tags that point at fetched commits
--upload-pack=<path>Override the path to git-upload-pack on the remote (for non-standard installs)
--depth=<n>Create a shallow history truncated to n commits per branch
--no-progressDo not emit progress meters — useful in scripts
--check-self-contained-and-connectedVerify the received pack is fully connected before installing
--cloningInternal flag set when called from git clone — relaxes some checks

💡 Use cases

🧪 Examples

Fetch a single branch from a local daemon
git fetch-pack --no-progress git://127.0.0.1/repo.git refs/heads/main
Shallow fetch of depth 1
git fetch-pack --depth=1 git@github.com:user/repo.git refs/heads/main
Use a custom upload-pack binary
git fetch-pack --upload-pack=/opt/custom/git-upload-pack ssh://host/repo refs/heads/*
Verbose negotiation trace
GIT_TRACE_PACKET=1 git fetch-pack -v --all git://127.0.0.1/repo.git

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.