Documentation / git-bundle.txton commit fast-import: duplicate into history rather than passing ownership (1ebec8d)
   1git-bundle(1)
   2=============
   3
   4NAME
   5----
   6git-bundle - Move objects and refs by archive
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git bundle' create <file> <git-rev-list-args>
  13'git bundle' verify <file>
  14'git bundle' list-heads <file> [<refname>...]
  15'git bundle' unbundle <file> [<refname>...]
  16
  17DESCRIPTION
  18-----------
  19
  20Some workflows require that one or more branches of development on one
  21machine be replicated on another machine, but the two machines cannot
  22be directly connected, and therefore the interactive Git protocols (git,
  23ssh, http) cannot be used.  This command provides support for
  24'git fetch' and 'git pull' to operate by packaging objects and references
  25in an archive at the originating machine, then importing those into
  26another repository using 'git fetch' and 'git pull'
  27after moving the archive by some means (e.g., by sneakernet).  As no
  28direct connection between the repositories exists, the user must specify a
  29basis for the bundle that is held by the destination repository: the
  30bundle assumes that all objects in the basis are already in the
  31destination repository.
  32
  33OPTIONS
  34-------
  35
  36create <file>::
  37        Used to create a bundle named 'file'.  This requires the
  38        'git-rev-list-args' arguments to define the bundle contents.
  39
  40verify <file>::
  41        Used to check that a bundle file is valid and will apply
  42        cleanly to the current repository.  This includes checks on the
  43        bundle format itself as well as checking that the prerequisite
  44        commits exist and are fully linked in the current repository.
  45        'git bundle' prints a list of missing commits, if any, and exits
  46        with a non-zero status.
  47
  48list-heads <file>::
  49        Lists the references defined in the bundle.  If followed by a
  50        list of references, only references matching those given are
  51        printed out.
  52
  53unbundle <file>::
  54        Passes the objects in the bundle to 'git index-pack'
  55        for storage in the repository, then prints the names of all
  56        defined references. If a list of references is given, only
  57        references matching those in the list are printed. This command is
  58        really plumbing, intended to be called only by 'git fetch'.
  59
  60<git-rev-list-args>::
  61        A list of arguments, acceptable to 'git rev-parse' and
  62        'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES
  63        below), that specifies the specific objects and references
  64        to transport.  For example, `master~10..master` causes the
  65        current master reference to be packaged along with all objects
  66        added since its 10th ancestor commit.  There is no explicit
  67        limit to the number of references and objects that may be
  68        packaged.
  69
  70
  71[<refname>...]::
  72        A list of references used to limit the references reported as
  73        available. This is principally of use to 'git fetch', which
  74        expects to receive only those references asked for and not
  75        necessarily everything in the pack (in this case, 'git bundle' acts
  76        like 'git fetch-pack').
  77
  78SPECIFYING REFERENCES
  79---------------------
  80
  81'git bundle' will only package references that are shown by
  82'git show-ref': this includes heads, tags, and remote heads.  References
  83such as `master~1` cannot be packaged, but are perfectly suitable for
  84defining the basis.  More than one reference may be packaged, and more
  85than one basis can be specified.  The objects packaged are those not
  86contained in the union of the given bases.  Each basis can be
  87specified explicitly (e.g. `^master~10`), or implicitly (e.g.
  88`master~10..master`, `--since=10.days.ago master`).
  89
  90It is very important that the basis used be held by the destination.
  91It is okay to err on the side of caution, causing the bundle file
  92to contain objects already in the destination, as these are ignored
  93when unpacking at the destination.
  94
  95EXAMPLES
  96--------
  97
  98Assume you want to transfer the history from a repository R1 on machine A
  99to another repository R2 on machine B.
 100For whatever reason, direct connection between A and B is not allowed,
 101but we can move data from A to B via some mechanism (CD, email, etc.).
 102We want to update R2 with development made on the branch master in R1.
 103
 104To bootstrap the process, you can first create a bundle that does not have
 105any basis. You can use a tag to remember up to what commit you last
 106processed, in order to make it easy to later update the other repository
 107with an incremental bundle:
 108
 109----------------
 110machineA$ cd R1
 111machineA$ git bundle create file.bundle master
 112machineA$ git tag -f lastR2bundle master
 113----------------
 114
 115Then you transfer file.bundle to the target machine B. Because this
 116bundle does not require any existing object to be extracted, you can
 117create a new repository on machine B by cloning from it:
 118
 119----------------
 120machineB$ git clone -b master /home/me/tmp/file.bundle R2
 121----------------
 122
 123This will define a remote called "origin" in the resulting repository that
 124lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
 125have an entry like this:
 126
 127------------------------
 128[remote "origin"]
 129    url = /home/me/tmp/file.bundle
 130    fetch = refs/heads/*:refs/remotes/origin/*
 131------------------------
 132
 133To update the resulting mine.git repository, you can fetch or pull after
 134replacing the bundle stored at /home/me/tmp/file.bundle with incremental
 135updates.
 136
 137After working some more in the original repository, you can create an
 138incremental bundle to update the other repository:
 139
 140----------------
 141machineA$ cd R1
 142machineA$ git bundle create file.bundle lastR2bundle..master
 143machineA$ git tag -f lastR2bundle master
 144----------------
 145
 146You then transfer the bundle to the other machine to replace
 147/home/me/tmp/file.bundle, and pull from it.
 148
 149----------------
 150machineB$ cd R2
 151machineB$ git pull
 152----------------
 153
 154If you know up to what commit the intended recipient repository should
 155have the necessary objects, you can use that knowledge to specify the
 156basis, giving a cut-off point to limit the revisions and objects that go
 157in the resulting bundle. The previous example used the lastR2bundle tag
 158for this purpose, but you can use any other options that you would give to
 159the linkgit:git-log[1] command. Here are more examples:
 160
 161You can use a tag that is present in both:
 162
 163----------------
 164$ git bundle create mybundle v1.0.0..master
 165----------------
 166
 167You can use a basis based on time:
 168
 169----------------
 170$ git bundle create mybundle --since=10.days master
 171----------------
 172
 173You can use the number of commits:
 174
 175----------------
 176$ git bundle create mybundle -10 master
 177----------------
 178
 179You can run `git-bundle verify` to see if you can extract from a bundle
 180that was created with a basis:
 181
 182----------------
 183$ git bundle verify mybundle
 184----------------
 185
 186This will list what commits you must have in order to extract from the
 187bundle and will error out if you do not have them.
 188
 189A bundle from a recipient repository's point of view is just like a
 190regular repository which it fetches or pulls from. You can, for example, map
 191references when fetching:
 192
 193----------------
 194$ git fetch mybundle master:localRef
 195----------------
 196
 197You can also see what references it offers:
 198
 199----------------
 200$ git ls-remote mybundle
 201----------------
 202
 203GIT
 204---
 205Part of the linkgit:git[1] suite