git-fetch-pack
Receive missing Git objects from another repository
SYNOPSIS
git fetch-pack [--all] [--quiet] [--keep] [--thin] [--no-progress] [--check-self-contained-and-connected] [--dry-run] [--verbose] [--upload-pack=git-upload-pack] [--exec=git-upload-pack] [--depth=depth] [--deepen-since=timestamp] [--deepen-not=revision] [--negotiation-tip=revision] [--max-pack-size=bytes] [--filter=filter-spec] [--ref-delta] repository [ref...]
PARAMETERS
--all
Fetch all refs found on the remote, instead of specific ones.
--quiet
Suppress progress reporting and error messages.
--keep
Do not delete the fetched packfile after unpacking. Normally, packfiles are deleted if they are not stored permanently.
--thin
Allow the remote to send a thin pack, which omits objects that are known to exist locally.
--no-progress
Do not show progress status.
--check-self-contained-and-connected
Check that the received pack is self-contained and connected.
--dry-run
Don't actually fetch anything, just report what would be fetched.
--verbose
Report more details during the fetch process.
--upload-pack=git-upload-pack
Path to the git-upload-pack program on the remote host. Useful if it's not in the default PATH.
--exec=git-upload-pack
Same as --upload-pack, but implies using SSH protocol.
--depth=depth
Limit fetching to a specified number of commits from the tips of the branches. Used for shallow clones.
--filter=filter-spec
Request a partial clone, filtering objects based on the provided spec (e.g., 'blob:none' to exclude all blobs).
--ref-delta
Allow the remote to send ref-delta objects, which can reduce network traffic for large repositories.
repository
The URL or path to the remote repository.
ref...
A list of references (e.g., branch names, commit SHAs) to fetch from the remote repository.
DESCRIPTION
The git-fetch-pack command is a low-level plumbing command used by other Git commands, such as git fetch, git pull, and git clone, to communicate with a remote repository's git-upload-pack instance.
Its primary function is to negotiate and transfer Git objects (commits, trees, blobs, and tags) from the remote repository to the local one. It determines which objects are missing locally, requests them from the remote, and receives them, often in the form of a packfile. This process involves a negotiation phase where both sides determine the most efficient way to transfer only the necessary objects.
Users typically do not invoke git-fetch-pack directly. Instead, they use the higher-level commands that wrap its functionality, providing a more user-friendly interface for common operations like fetching updates or cloning repositories.
CAVEATS
git-fetch-pack is a plumbing command, meaning it's part of Git's internal machinery and is generally not intended for direct use by end-users. Improper direct invocation can lead to unexpected behavior or an incomplete understanding of Git's state. It relies heavily on its counterpart, git-upload-pack, on the remote side for successful operation.
While it provides fine-grained control over the fetching process, higher-level commands like git fetch encapsulate this complexity and are safer and more convenient for most use cases.
INTERNAL COMMUNICATION
git-fetch-pack establishes a connection with the remote's git-upload-pack process, which is responsible for serving the requested Git objects. This client-server interaction forms the backbone of Git's network operations.
PACKFILE TRANSFER
One of its key functions is the efficient transfer of objects via packfiles. A packfile is a single file containing multiple Git objects (commits, trees, blobs, tags) compressed together, along with an index file for quick lookup. This significantly reduces the overhead of transferring many small objects individually.
HISTORY
As a core component of Git's remote communication protocol, git-fetch-pack has been fundamental to Git's design since its early days. It embodies the pack protocol, which was introduced to efficiently transfer Git objects over the network by packaging them into a single, compressed file (packfile). Its evolution has mirrored the development of Git itself, with new options added over time to support features like shallow cloning, partial cloning (object filtering), and improved negotiation strategies to optimize network transfers.
SEE ALSO
git-upload-pack(1), git-fetch(1), git-pull(1), git-clone(1)