<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="git-bundle(1)">
<articleinfo>
    <title>git-bundle(1)</title>
        <indexterm>
                <primary>git-bundle(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-bundle - Move objects and refs by archive</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git bundle</emphasis> create &lt;file&gt; &lt;git-rev-list args&gt;
<emphasis>git bundle</emphasis> verify &lt;file&gt;
<emphasis>git bundle</emphasis> list-heads &lt;file&gt; [refname&#8230;]
<emphasis>git bundle</emphasis> unbundle &lt;file&gt; [refname&#8230;]</literallayout>
</blockquote>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>Some workflows require that one or more branches of development on one
machine be replicated on another machine, but the two machines cannot
be directly connected so the interactive git protocols (git, ssh,
rsync, http) cannot be used.  This command provides support for
<emphasis>git-fetch</emphasis> and <emphasis>git-pull</emphasis> to operate by packaging objects and references
in an archive at the originating machine, then importing those into
another repository using <emphasis>git-fetch</emphasis> and <emphasis>git-pull</emphasis>
after moving the archive by some means (i.e., by sneakernet).  As no
direct connection between repositories exists, the user must specify a
basis for the bundle that is held by the destination repository: the
bundle assumes that all objects in the basis are already in the
destination repository.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
create &lt;file&gt;
</term>
<listitem>
<simpara>
       Used to create a bundle named <emphasis>file</emphasis>.  This requires the
       <emphasis>git-rev-list</emphasis> arguments to define the bundle contents.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
verify &lt;file&gt;
</term>
<listitem>
<simpara>
       Used to check that a bundle file is valid and will apply
       cleanly to the current repository.  This includes checks on the
       bundle format itself as well as checking that the prerequisite
       commits exist and are fully linked in the current repository.
       <emphasis>git-bundle</emphasis> prints a list of missing commits, if any, and exits
       with non-zero status.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
list-heads &lt;file&gt;
</term>
<listitem>
<simpara>
       Lists the references defined in the bundle.  If followed by a
       list of references, only references matching those given are
       printed out.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
unbundle &lt;file&gt;
</term>
<listitem>
<simpara>
       Passes the objects in the bundle to <emphasis>git-index-pack</emphasis>
       for storage in the repository, then prints the names of all
       defined references. If a reflist is given, only references
       matching those in the given list are printed. This command is
       really plumbing, intended to be called only by <emphasis>git-fetch</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
[git-rev-list-args&#8230;]
</term>
<listitem>
<simpara>
       A list of arguments, acceptable to <emphasis>git-rev-parse</emphasis> and
       <emphasis>git-rev-list</emphasis>, that specify the specific objects and references
       to transport.  For example, "master~10..master" causes the
       current master reference to be packaged along with all objects
       added since its 10th ancestor commit.  There is no explicit
       limit to the number of references and objects that may be
       packaged.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
[refname&#8230;]
</term>
<listitem>
<simpara>
       A list of references used to limit the references reported as
       available. This is principally of use to <emphasis>git-fetch</emphasis>, which
       expects to receive only those references asked for and not
       necessarily everything in the pack (in this case, <emphasis>git-bundle</emphasis> is
       acting like <emphasis>git-fetch-pack</emphasis>).
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_specifying_references">
<title>SPECIFYING REFERENCES</title>
<simpara><emphasis>git-bundle</emphasis> will only package references that are shown by
<emphasis>git-show-ref</emphasis>: this includes heads, tags, and remote heads.  References
such as master<subscript>1 cannot be packaged, but are perfectly suitable for
defining the basis.  More than one reference may be packaged, and more
than one basis can be specified.  The objects packaged are those not
contained in the union of the given bases.  Each basis can be
specified explicitly (e.g., ^master</subscript>10), or implicitly (e.g.,
master~10..master, --since=10.days.ago master).</simpara>
<simpara>It is very important that the basis used be held by the destination.
It is okay to err on the side of conservatism, causing the bundle file
to contain objects already in the destination as these are ignored
when unpacking at the destination.</simpara>
</simplesect>
<simplesect id="_example">
<title>EXAMPLE</title>
<simpara>Assume you want to transfer the history from a repository R1 on machine A
to another repository R2 on machine B.
For whatever reason, direct connection between A and B is not allowed,
but we can move data from A to B via some mechanism (CD, email, etc).
We want to update R2 with developments made on branch master in R1.</simpara>
<simpara>To bootstrap the process, you can first create a bundle that doesn&#8217;t have
any basis. You can use a tag to remember up to what commit you sent out
in order to make it easy to later update the other repository with
incremental bundle,</simpara>
<literallayout>machineA$ cd R1
machineA$ git bundle create file.bdl master
machineA$ git tag -f lastR2bundle master</literallayout>
<simpara>Then you sneakernet file.bdl to the target machine B. Because you don&#8217;t
have to have any object to extract objects from such a bundle, not only
you can fetch/pull from a bundle, you can clone from it as if it was a
remote repository.</simpara>
<literallayout>machineB$ git clone /home/me/tmp/file.bdl R2</literallayout>
<simpara>This will define a remote called "origin" in the resulting repository that
lets you fetch and pull from the bundle. $GIT_DIR/config file in R2 may
have an entry like this:</simpara>
<literallayout>[remote "origin"]
    url = /home/me/tmp/file.bdl
    fetch = refs/heads/*:refs/remotes/origin/*</literallayout>
<simpara>You can fetch/pull to update the resulting mine.git repository after
replacing the bundle you store at /home/me/tmp/file.bdl with incremental
updates from here on.</simpara>
<simpara>After working more in the original repository, you can create an
incremental bundle to update the other:</simpara>
<literallayout>machineA$ cd R1
machineA$ git bundle create file.bdl lastR2bundle..master
machineA$ git tag -f lastR2bundle master</literallayout>
<simpara>and sneakernet it to the other machine to replace /home/me/tmp/file.bdl,
and pull from it.</simpara>
<literallayout>machineB$ cd R2
machineB$ git pull</literallayout>
<simpara>If you know up to what commit the intended recipient repository should
have the necessary objects for, you can use that knowledge to specify the
basis, giving a cut-off point to limit the revisions and objects that go
in the resulting bundle. The previous example used lastR2bundle tag
for this purpose, but you can use other options you would give to
the <xref linkend="git-log(1)"/> command. Here are more examples:</simpara>
<simpara>You can use a tag that is present in both.</simpara>
<literallayout>$ git bundle create mybundle v1.0.0..master</literallayout>
<simpara>You can use a basis based on time.</simpara>
<literallayout>$ git bundle create mybundle --since=10.days master</literallayout>
<simpara>Or you can use the number of commits.</simpara>
<literallayout>$ git bundle create mybundle -10 master</literallayout>
<simpara>You can run <literal>git-bundle verify</literal> to see if you can extract from a bundle
that was created with a basis.</simpara>
<literallayout>$ git bundle verify mybundle</literallayout>
<simpara>This will list what commits you must have in order to extract from the
bundle and will error out if you don&#8217;t have them.</simpara>
<simpara>A bundle from a recipient repository&#8217;s point of view is just like a
regular repository it fetches/pulls from. You can for example map
refs, like this example, when fetching:</simpara>
<literallayout>$ git fetch mybundle master:localRef</literallayout>
<simpara>Or see what refs it offers.</simpara>
<literallayout>$ git ls-remote mybundle</literallayout>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Mark Levedahl &lt;<ulink url="mailto:mdl123@verizon.net">mdl123@verizon.net</ulink>&gt;</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
