6 git-bundle - Move objects and refs by archive
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>...]
20 Some workflows require that one or more branches of development on one
21 machine be replicated on another machine, but the two machines cannot
22 be directly connected, and therefore the interactive Git protocols (git,
23 ssh, http) cannot be used.
25 The 'git bundle' command packages objects and references in an archive
26 at the originating machine, which can then be imported into another
27 repository using 'git fetch', 'git pull', or 'git clone',
28 after moving the archive by some means (e.g., by sneakernet).
31 direct connection between the repositories exists, the user must specify a
32 basis for the bundle that is held by the destination repository: the
33 bundle assumes that all objects in the basis are already in the
34 destination repository.
40 Used to create a bundle named 'file'. This requires the
41 '<git-rev-list-args>' arguments to define the bundle contents.
44 Used to check that a bundle file is valid and will apply
45 cleanly to the current repository. This includes checks on the
46 bundle format itself as well as checking that the prerequisite
47 commits exist and are fully linked in the current repository.
48 'git bundle' prints a list of missing commits, if any, and exits
49 with a non-zero status.
52 Lists the references defined in the bundle. If followed by a
53 list of references, only references matching those given are
57 Passes the objects in the bundle to 'git index-pack'
58 for storage in the repository, then prints the names of all
59 defined references. If a list of references is given, only
60 references matching those in the list are printed. This command is
61 really plumbing, intended to be called only by 'git fetch'.
64 A list of arguments, acceptable to 'git rev-parse' and
65 'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES
66 below), that specifies the specific objects and references
67 to transport. For example, `master~10..master` causes the
68 current master reference to be packaged along with all objects
69 added since its 10th ancestor commit. There is no explicit
70 limit to the number of references and objects that may be
75 A list of references used to limit the references reported as
76 available. This is principally of use to 'git fetch', which
77 expects to receive only those references asked for and not
78 necessarily everything in the pack (in this case, 'git bundle' acts
79 like 'git fetch-pack').
84 'git bundle' will only package references that are shown by
85 'git show-ref': this includes heads, tags, and remote heads. References
86 such as `master~1` cannot be packaged, but are perfectly suitable for
87 defining the basis. More than one reference may be packaged, and more
88 than one basis can be specified. The objects packaged are those not
89 contained in the union of the given bases. Each basis can be
90 specified explicitly (e.g. `^master~10`), or implicitly (e.g.
91 `master~10..master`, `--since=10.days.ago master`).
93 It is very important that the basis used be held by the destination.
94 It is okay to err on the side of caution, causing the bundle file
95 to contain objects already in the destination, as these are ignored
96 when unpacking at the destination.
98 `git clone` can use any bundle created without negative refspecs
99 (e.g., `new`, but not `old..new`).
100 If you want to match `git clone --mirror`, which would include your
101 refs such as `refs/remotes/*`, use `--all`.
102 If you want to provide the same set of refs that a clone directly
103 from the source repository would get, use `--branches --tags` for
104 the `<git-rev-list-args>`.
109 Assume you want to transfer the history from a repository R1 on machine A
110 to another repository R2 on machine B.
111 For whatever reason, direct connection between A and B is not allowed,
112 but we can move data from A to B via some mechanism (CD, email, etc.).
113 We want to update R2 with development made on the branch master in R1.
115 To bootstrap the process, you can first create a bundle that does not have
116 any basis. You can use a tag to remember up to what commit you last
117 processed, in order to make it easy to later update the other repository
118 with an incremental bundle:
122 machineA$ git bundle create file.bundle master
123 machineA$ git tag -f lastR2bundle master
126 Then you transfer file.bundle to the target machine B. Because this
127 bundle does not require any existing object to be extracted, you can
128 create a new repository on machine B by cloning from it:
131 machineB$ git clone -b master /home/me/tmp/file.bundle R2
134 This will define a remote called "origin" in the resulting repository that
135 lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
136 have an entry like this:
138 ------------------------
140 url = /home/me/tmp/file.bundle
141 fetch = refs/heads/*:refs/remotes/origin/*
142 ------------------------
144 To update the resulting mine.git repository, you can fetch or pull after
145 replacing the bundle stored at /home/me/tmp/file.bundle with incremental
148 After working some more in the original repository, you can create an
149 incremental bundle to update the other repository:
153 machineA$ git bundle create file.bundle lastR2bundle..master
154 machineA$ git tag -f lastR2bundle master
157 You then transfer the bundle to the other machine to replace
158 /home/me/tmp/file.bundle, and pull from it.
165 If you know up to what commit the intended recipient repository should
166 have the necessary objects, you can use that knowledge to specify the
167 basis, giving a cut-off point to limit the revisions and objects that go
168 in the resulting bundle. The previous example used the lastR2bundle tag
169 for this purpose, but you can use any other options that you would give to
170 the linkgit:git-log[1] command. Here are more examples:
172 You can use a tag that is present in both:
175 $ git bundle create mybundle v1.0.0..master
178 You can use a basis based on time:
181 $ git bundle create mybundle --since=10.days master
184 You can use the number of commits:
187 $ git bundle create mybundle -10 master
190 You can run `git-bundle verify` to see if you can extract from a bundle
191 that was created with a basis:
194 $ git bundle verify mybundle
197 This will list what commits you must have in order to extract from the
198 bundle and will error out if you do not have them.
200 A bundle from a recipient repository's point of view is just like a
201 regular repository which it fetches or pulls from. You can, for example, map
202 references when fetching:
205 $ git fetch mybundle master:localRef
208 You can also see what references it offers:
211 $ git ls-remote mybundle
216 Part of the linkgit:git[1] suite