LinuxCommandLibrary

git-send-pack

Transmit objects to another repository

SYNOPSIS

git-send-pack [--all] [--dry-run] [--force] [-f] [--receive-pack=<git-receive-pack>] [--stat[=<regex>]] [--thin | --no-thin] [--verbose] [-v] <host>:<directory> [<ref> ...]

PARAMETERS

--all
    Update all heads (refs/heads/) that locally exist

--dry-run
    Simulate push without sending updates

--force, -f
    Allow non-fast-forward updates (dangerous)

--receive-pack=<git-receive-pack>
    Specify path to remote git-receive-pack program

--stat[=<regex>]
    Report progress, optionally filtered by regex

--thin, --no-thin
    Use thin packfile (deltas within pack); default thin in modern Git

--verbose, -v
    Enable verbose output during operation

DESCRIPTION

git-send-pack is a low-level plumbing command in Git used to transmit objects and references from a local repository to a remote one over the native Git protocol. It serves as the client-side counterpart to git-receive-pack on the server. Typically invoked internally by git-push, it constructs a packfile of necessary objects (using git-pack-objects) and sends it along with commands to create or update remote refs.

This command enables efficient transfer by supporting thin packs, which store deltas relative to other objects in the same pack rather than full blobs. It handles multiple ref updates in a single invocation, ensuring atomicity where possible. Options allow dry-run testing, verbose output, and customization of the remote receive-pack binary.

Direct usage is rare for end-users due to complexity and risk of ref corruption; it's designed for scripted or automated pushes. Security relies on SSH or other transports for authentication, with capabilities negotiated via protocol v2 features in modern Git.

CAVEATS

Internal command; prefer git-push for safety.
--force can overwrite history irreversibly.
Requires network access and remote permissions.
Not interactive; errors halt process.

REF SPECIFICATION

Refs as <src>:<dst> or just <dst> (src=HEAD); supports deletions with <src>: (empty dst)

TRANSPORT

Uses git:// or ssh://; host:directory format, e.g., origin:/path/to/repo.git

HISTORY

Introduced in Git 0.99 (2005) by Linus Torvalds as core push mechanism.
Evolved with protocol versions: v0 basic, v1 capabilities, v2 (Git 2.0+) for efficiency.
Thin packs added in Git 1.7.0 (2010); now mostly internal to porcelain commands.

SEE ALSO

Copied to clipboard