6 git-bundle - Move objects and refs by archive
12 'git bundle' create [-q | --quiet | --progress | --all-progress] [--all-progress-implied]
13 [--version=<version>] <file> <git-rev-list-args>
14 'git bundle' verify [-q | --quiet] <file>
15 'git bundle' list-heads <file> [<refname>...]
16 'git bundle' unbundle [--progress] <file> [<refname>...]
21 Create, unpack, and manipulate "bundle" files. Bundles are used for
22 the "offline" transfer of Git objects without an active "server"
23 sitting on the other side of the network connection.
25 They can be used to create both incremental and full backups of a
26 repository, and to relay the state of the references in one repository
29 Git commands that fetch or otherwise "read" via protocols such as
30 `ssh://` and `https://` can also operate on bundle files. It is
31 possible linkgit:git-clone[1] a new repository from a bundle, to use
32 linkgit:git-fetch[1] to fetch from one, and to list the references
33 contained within it with linkgit:git-ls-remote[1]. There's no
34 corresponding "write" support, i.e.a 'git push' into a bundle is not
37 See the "EXAMPLES" section below for examples of how to use bundles.
42 Bundles are `.pack` files (see linkgit:git-pack-objects[1]) with a
43 header indicating what references are contained within the bundle.
45 Like the the packed archive format itself bundles can either be
46 self-contained, or be created using exclusions.
47 See the "OBJECT PREREQUISITES" section below.
49 Bundles created using revision exclusions are "thin packs" created
50 using the `--thin` option to linkgit:git-pack-objects[1], and
51 unbundled using the `--fix-thin` option to linkgit:git-index-pack[1].
53 There is no option to create a "thick pack" when using revision
54 exclusions, and users should not be concerned about the difference. By
55 using "thin packs", bundles created using exclusions are smaller in
56 size. That they're "thin" under the hood is merely noted here as a
57 curiosity, and as a reference to other documentation.
59 See link:technical/bundle-format.html[the `bundle-format`
60 documentation] for more details and the discussion of "thin pack" in
61 link:technical/pack-format.html[the pack format documentation] for
67 create [options] <file> <git-rev-list-args>::
68 Used to create a bundle named 'file'. This requires the
69 '<git-rev-list-args>' arguments to define the bundle contents.
70 'options' contains the options specific to the 'git bundle create'
74 Used to check that a bundle file is valid and will apply
75 cleanly to the current repository. This includes checks on the
76 bundle format itself as well as checking that the prerequisite
77 commits exist and are fully linked in the current repository.
78 'git bundle' prints a list of missing commits, if any, and exits
79 with a non-zero status.
82 Lists the references defined in the bundle. If followed by a
83 list of references, only references matching those given are
87 Passes the objects in the bundle to 'git index-pack'
88 for storage in the repository, then prints the names of all
89 defined references. If a list of references is given, only
90 references matching those in the list are printed. This command is
91 really plumbing, intended to be called only by 'git fetch'.
94 A list of arguments, acceptable to 'git rev-parse' and
95 'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES
96 below), that specifies the specific objects and references
97 to transport. For example, `master~10..master` causes the
98 current master reference to be packaged along with all objects
99 added since its 10th ancestor commit. There is no explicit
100 limit to the number of references and objects that may be
105 A list of references used to limit the references reported as
106 available. This is principally of use to 'git fetch', which
107 expects to receive only those references asked for and not
108 necessarily everything in the pack (in this case, 'git bundle' acts
109 like 'git fetch-pack').
112 Progress status is reported on the standard error stream
113 by default when it is attached to a terminal, unless -q
114 is specified. This flag forces progress status even if
115 the standard error stream is not directed to a terminal.
118 When --stdout is specified then progress report is
119 displayed during the object count and compression phases
120 but inhibited during the write-out phase. The reason is
121 that in some cases the output stream is directly linked
122 to another command which may wish to display progress
123 status of its own as it processes incoming pack data.
124 This flag is like --progress except that it forces progress
125 report for the write-out phase as well even if --stdout is
128 --all-progress-implied::
129 This is used to imply --all-progress whenever progress display
130 is activated. Unlike --all-progress this flag doesn't actually
131 force any progress display by itself.
133 --version=<version>::
134 Specify the bundle version. Version 2 is the older format and can only be
135 used with SHA-1 repositories; the newer version 3 contains capabilities that
136 permit extensions. The default is the oldest supported format, based on the
137 hash algorithm in use.
141 This flag makes the command not to report its progress
142 on the standard error stream.
144 SPECIFYING REFERENCES
145 ---------------------
147 Revisions must be accompanied by reference names to be packaged in a
150 More than one reference may be packaged, and more than one set of prerequisite objects can
151 be specified. The objects packaged are those not contained in the
152 union of the prerequisites.
154 The 'git bundle create' command resolves the reference names for you
155 using the same rules as `git rev-parse --abbrev-ref=loose`. Each
156 prerequisite can be specified explicitly (e.g. `^master~10`), or implicitly
157 (e.g. `master~10..master`, `--since=10.days.ago master`).
159 All of these simple cases are OK (assuming we have a "master" and
163 $ git bundle create master.bundle master
164 $ echo master | git bundle create master.bundle --stdin
165 $ git bundle create master-and-next.bundle master next
166 $ (echo master; echo next) | git bundle create master-and-next.bundle --stdin
169 And so are these (and the same but omitted `--stdin` examples):
172 $ git bundle create recent-master.bundle master~10..master
173 $ git bundle create recent-updates.bundle master~10..master next~5..next
176 A revision name or a range whose right-hand-side cannot be resolved to
177 a reference is not accepted:
180 $ git bundle create HEAD.bundle $(git rev-parse HEAD)
181 fatal: Refusing to create empty bundle.
182 $ git bundle create master-yesterday.bundle master~10..master~5
183 fatal: Refusing to create empty bundle.
189 When creating bundles it is possible to create a self-contained bundle
190 that can be unbundled in a repository with no common history, as well
191 as providing negative revisions to exclude objects needed in the
192 earlier parts of the history.
194 Feeding a revision such as `new` to `git bundle create` will create a
195 bundle file that contains all the objects reachable from the revision
196 `new`. That bundle can be unbundled in any repository to obtain a full
197 history that leads to the revision `new`:
200 $ git bundle create full.bundle new
203 A revision range such as `old..new` will produce a bundle file that
204 will require the revision `old` (and any objects reachable from it)
205 to exist for the bundle to be "unbundle"-able:
208 $ git bundle create full.bundle old..new
211 A self-contained bundle without any prerequisites can be extracted
212 into anywhere, even into an empty repository, or be cloned from
213 (i.e., `new`, but not `old..new`).
215 It is okay to err on the side of caution, causing the bundle file
216 to contain objects already in the destination, as these are ignored
217 when unpacking at the destination.
219 If you want to match `git clone --mirror`, which would include your
220 refs such as `refs/remotes/*`, use `--all`.
221 If you want to provide the same set of refs that a clone directly
222 from the source repository would get, use `--branches --tags` for
223 the `<git-rev-list-args>`.
225 The 'git bundle verify' command can be used to check whether your
226 recipient repository has the required prerequisite commits for a
232 Assume you want to transfer the history from a repository R1 on machine A
233 to another repository R2 on machine B.
234 For whatever reason, direct connection between A and B is not allowed,
235 but we can move data from A to B via some mechanism (CD, email, etc.).
236 We want to update R2 with development made on the branch master in R1.
238 To bootstrap the process, you can first create a bundle that does not have
239 any prerequisites. You can use a tag to remember up to what commit you last
240 processed, in order to make it easy to later update the other repository
241 with an incremental bundle:
245 machineA$ git bundle create file.bundle master
246 machineA$ git tag -f lastR2bundle master
249 Then you transfer file.bundle to the target machine B. Because this
250 bundle does not require any existing object to be extracted, you can
251 create a new repository on machine B by cloning from it:
254 machineB$ git clone -b master /home/me/tmp/file.bundle R2
257 This will define a remote called "origin" in the resulting repository that
258 lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
259 have an entry like this:
261 ------------------------
263 url = /home/me/tmp/file.bundle
264 fetch = refs/heads/*:refs/remotes/origin/*
265 ------------------------
267 To update the resulting mine.git repository, you can fetch or pull after
268 replacing the bundle stored at /home/me/tmp/file.bundle with incremental
271 After working some more in the original repository, you can create an
272 incremental bundle to update the other repository:
276 machineA$ git bundle create file.bundle lastR2bundle..master
277 machineA$ git tag -f lastR2bundle master
280 You then transfer the bundle to the other machine to replace
281 /home/me/tmp/file.bundle, and pull from it.
288 If you know up to what commit the intended recipient repository should
289 have the necessary objects, you can use that knowledge to specify the
290 prerequisites, giving a cut-off point to limit the revisions and objects that go
291 in the resulting bundle. The previous example used the lastR2bundle tag
292 for this purpose, but you can use any other options that you would give to
293 the linkgit:git-log[1] command. Here are more examples:
295 You can use a tag that is present in both:
298 $ git bundle create mybundle v1.0.0..master
301 You can use a prerequisite based on time:
304 $ git bundle create mybundle --since=10.days master
307 You can use the number of commits:
310 $ git bundle create mybundle -10 master
313 You can run `git-bundle verify` to see if you can extract from a bundle
314 that was created with a prerequisite:
317 $ git bundle verify mybundle
320 This will list what commits you must have in order to extract from the
321 bundle and will error out if you do not have them.
323 A bundle from a recipient repository's point of view is just like a
324 regular repository which it fetches or pulls from. You can, for example, map
325 references when fetching:
328 $ git fetch mybundle master:localRef
331 You can also see what references it offers:
334 $ git ls-remote mybundle
339 Part of the linkgit:git[1] suite