LinuxCommandLibrary

git-bundle

Package Git repository for transport

TLDR

Create a bundle file that contains all objects and references of a specific branch

$ git bundle create [path/to/file.bundle] [branch_name]
copy

Create a bundle file of all branches
$ git bundle create [path/to/file.bundle] --all
copy

Create a bundle file of the last 5 commits of the current branch
$ git bundle create [path/to/file.bundle] -5 [HEAD]
copy

Create a bundle file of the latest 7 days
$ git bundle create [path/to/file.bundle] --since 7.days [HEAD]
copy

Verify that a bundle file is valid and can be applied to the current repository
$ git bundle verify [path/to/file.bundle]
copy

Print to stdout the list of references contained in a bundle
$ git bundle unbundle [path/to/file.bundle]
copy

Unbundle a specific branch from a bundle file into the current repository
$ git pull [path/to/file.bundle] [branch_name]
copy

Create a new repository from a bundle
$ git clone [path/to/file.bundle]
copy

SYNOPSIS

git bundle create [options...] <file> <git-rev-list args>
git bundle verify [-q|-v| --strict] <file>
git bundle list-heads [-v] <file> [<refname>...]
git bundle unbundle <file> [<refname>...]

PARAMETERS

create
    Create a new bundle file with specified objects and refs.

verify
    Validate bundle integrity and prerequisites.

list-heads
    List refs (heads/tags) in the bundle.

unbundle
    Extract objects/refs from bundle to current repo.

<file>
    Path to bundle file (required for most subcommands).

--progress
    Show progress on stderr (create).

--all-progress
    Enable progress for all pack-objects (create).

--verbose
    Be more verbose (-v short form).

--all
    Include all refs found in refs/ namespace (create).

--since=<ref>
    Include objects newer than <ref> (create).

--max-count=<n>
    Limit to n most recent objects (create).

--depth=<n>
    Limit history depth to n (create).

-q
    Quiet mode, suppress output (verify).

--strict
    Fail if prerequisites missing (verify).

DESCRIPTION

The git bundle command creates a binary file that bundles Git objects (commits, trees, blobs) and references (branches, tags), enabling repository transfer without Git's network protocols. Ideal for email, HTTP, USB, or disconnected environments, it supports full snapshots or incremental updates.

Use create to generate a bundle from specified refs, like all branches or a commit range. Verify ensures integrity and prerequisites. List-heads shows included refs. Unbundle extracts to an existing repo via git fetch or git clone from bundle URL.

Bundles are efficient for occasional transfers but not real-time collaboration—prefer git push/git pull. Incremental bundles (e.g., since a ref) minimize size. They are forward-compatible but require recipient repo to have prerequisites. Widely used for distributing project snapshots or mirroring in air-gapped setups.

CAVEATS

Bundles are one-way and static; create new ones for updates. Recipient must have prerequisite commits or fetch fails. Large repos produce big files. Not for production sync—use git remotes. Binary format, not human-readable.

FULL REPO BUNDLE

git bundle create myrepo.bundle --all
Bundles all branches/tags for complete clone.

INCREMENTAL UPDATE

git bundle create update.bundle v1.0..master
Bundles new commits since v1.0 on master.

CLONE FROM BUNDLE

git clone /path/to/bundle.git repo
Or git fetch /path/to/bundle.bundle master:refs/remotes/origin/master.

HISTORY

Introduced in Git 1.5.1 (February 2007) for offline transfers. Enhanced in later versions with better progress reporting and rev-list integration. Remains key for air-gapped workflows despite modern alternatives like shallow clones.

SEE ALSO

Copied to clipboard