interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / git-bundle.adoc

375 lines · 13413 bytes Raw Blame History
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 [-q | --quiet | --progress]
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>...]
17
18DESCRIPTION
19-----------
20
21Create, unpack, and manipulate "bundle" files. Bundles are used for
22the "offline" transfer of Git objects without an active "server"
23sitting on the other side of the network connection.
24
25They can be used to create both incremental and full backups of a
26repository (see the "full backup" example in "EXAMPLES"), and to relay
27the state of the references in one repository to another (see the second
28example).
29
30Git commands that fetch or otherwise "read" via protocols such as
31`ssh://` and `https://` can also operate on bundle files. It is
32possible linkgit:git-clone[1] a new repository from a bundle, to use
33linkgit:git-fetch[1] to fetch from one, and to list the references
34contained within it with linkgit:git-ls-remote[1]. There's no
35corresponding "write" support, i.e. a 'git push' into a bundle is not
36supported.
37
38BUNDLE FORMAT
39-------------
40
41Bundles are `.pack` files (see linkgit:git-pack-objects[1]) with a
42header indicating what references are contained within the bundle.
43
44Like the packed archive format itself bundles can either be
45self-contained, or be created using exclusions.
46See the <<OBJECT_PREREQUISITES,"OBJECT PREREQUISITES">> section below.
47
48Bundles created using revision exclusions are "thin packs" created
49using the `--thin` option to linkgit:git-pack-objects[1], and
50unbundled using the `--fix-thin` option to linkgit:git-index-pack[1].
51
52There is no option to create a "thick pack" when using revision
53exclusions, and users should not be concerned about the difference. By
54using "thin packs", bundles created using exclusions are smaller in
55size. That they're "thin" under the hood is merely noted here as a
56curiosity, and as a reference to other documentation.
57
58See linkgit:gitformat-bundle[5] for more details and the discussion of
59"thin pack" in linkgit:gitformat-pack[5] for further details.
60
61OPTIONS
62-------
63
64create [options] <file> <git-rev-list-args>::
65 Used to create a bundle named 'file'. This requires the
66 '<git-rev-list-args>' arguments to define the bundle contents.
67 'options' contains the options specific to the 'git bundle create'
68 subcommand. If 'file' is `-`, the bundle is written to stdout.
69
70verify <file>::
71 Used to check that a bundle file is valid and will apply
72 cleanly to the current repository. This includes checks on the
73 bundle format itself as well as checking that the prerequisite
74 commits exist and are fully linked in the current repository.
75 Then, 'git bundle' prints a list of missing commits, if any.
76 Finally, information about additional capabilities, such as "object
77 filter", is printed. See "Capabilities" in linkgit:gitformat-bundle[5]
78 for more information. The exit code is zero for success, but will
79 be nonzero if the bundle file is invalid. If 'file' is `-`, the
80 bundle is read from stdin.
81
82list-heads <file>::
83 Lists the references defined in the bundle. If followed by a
84 list of references, only references matching those given are
85 printed out. If 'file' is `-`, the bundle is read from stdin.
86
87unbundle <file>::
88 Passes the objects in the bundle to 'git index-pack'
89 for storage in the repository, then prints the names of all
90 defined references. If a list of references is given, only
91 references matching those in the list are printed. This command is
92 really plumbing, intended to be called only by 'git fetch'.
93 If 'file' is `-`, the bundle is read from stdin.
94
95<git-rev-list-args>::
96 A list of arguments, acceptable to 'git rev-parse' and
97 'git rev-list' (and containing a named ref, see
98 <<SPECIFYING_REFERENCES,SPECIFYING REFERENCES>>
99 below), that specifies the specific objects and references
100 to transport. For example, `master~10..master` causes the
101 current master reference to be packaged along with all objects
102 added since its 10th ancestor commit. There is no explicit
103 limit to the number of references and objects that may be
104 packaged.
105
106
107[<refname>...]::
108 A list of references used to limit the references reported as
109 available. This is principally of use to 'git fetch', which
110 expects to receive only those references asked for and not
111 necessarily everything in the pack (in this case, 'git bundle' acts
112 like 'git fetch-pack').
113
114--progress::
115 Progress status is reported on the standard error stream
116 by default when it is attached to a terminal, unless -q
117 is specified. This flag forces progress status even if
118 the standard error stream is not directed to a terminal.
119
120--version=<version>::
121 Specify the bundle version. Version 2 is the older format and can only be
122 used with SHA-1 repositories; the newer version 3 contains capabilities that
123 permit extensions. The default is the oldest supported format, based on the
124 hash algorithm in use.
125
126-q::
127--quiet::
128 This flag makes the command not to report its progress
129 on the standard error stream.
130
131[[SPECIFYING_REFERENCES]]
132SPECIFYING REFERENCES
133---------------------
134
135Revisions must be accompanied by reference names to be packaged in a
136bundle. Alternatively `--all` can be used to package all refs.
137
138More than one reference may be packaged, and more than one set of prerequisite objects can
139be specified. The objects packaged are those not contained in the
140union of the prerequisites.
141
142The 'git bundle create' command resolves the reference names for you
143using the same rules as `git rev-parse --abbrev-ref=loose`. Each
144prerequisite can be specified explicitly (e.g. `^master~10`), or implicitly
145(e.g. `master~10..master`, `--since=10.days.ago master`).
146
147All of these simple cases are OK (assuming we have a "master" and
148"next" branch):
149
150----------------
151$ git bundle create master.bundle master
152$ echo master | git bundle create master.bundle --stdin
153$ git bundle create master-and-next.bundle master next
154$ (echo master; echo next) | git bundle create master-and-next.bundle --stdin
155----------------
156
157And so are these (and the same but omitted `--stdin` examples):
158
159----------------
160$ git bundle create recent-master.bundle master~10..master
161$ git bundle create recent-updates.bundle master~10..master next~5..next
162----------------
163
164A revision name or a range whose right-hand-side cannot be resolved to
165a reference is not accepted:
166
167----------------
168$ git bundle create HEAD.bundle $(git rev-parse HEAD)
169fatal: Refusing to create empty bundle.
170$ git bundle create master-yesterday.bundle master~10..master~5
171fatal: Refusing to create empty bundle.
172----------------
173
174[[OBJECT_PREREQUISITES]]
175OBJECT PREREQUISITES
176--------------------
177
178When creating bundles it is possible to create a self-contained bundle
179that can be unbundled in a repository with no common history, as well
180as providing negative revisions to exclude objects needed in the
181earlier parts of the history.
182
183Feeding a revision such as `new` to `git bundle create` will create a
184bundle file that contains all the objects reachable from the revision
185`new`. That bundle can be unbundled in any repository to obtain a full
186history that leads to the revision `new`:
187
188----------------
189$ git bundle create full.bundle new
190----------------
191
192A revision range such as `old..new` will produce a bundle file that
193will require the revision `old` (and any objects reachable from it)
194to exist for the bundle to be "unbundle"-able:
195
196----------------
197$ git bundle create full.bundle old..new
198----------------
199
200A self-contained bundle without any prerequisites can be extracted
201into anywhere, even into an empty repository, or be cloned from
202(i.e., `new`, but not `old..new`).
203
204It is okay to err on the side of caution, causing the bundle file
205to contain objects already in the destination, as these are ignored
206when unpacking at the destination.
207
208If you want to provide the same set of refs that a clone directly
209from the source repository would get, use `--branches --tags` for
210the `<git-rev-list-args>`.
211
212The 'git bundle verify' command can be used to check whether your
213recipient repository has the required prerequisite commits for a
214bundle.
215
216EXAMPLES
217--------
218
219We'll discuss two cases:
220
2211. Taking a full backup of a repository
2222. Transferring the history of a repository to another machine when the
223 two machines have no direct connection
224
225First let's consider a full backup of the repository. The following
226command will take a full backup of the repository in the sense that all
227refs are included in the bundle:
228
229----------------
230$ git bundle create backup.bundle --all
231----------------
232
233But note again that this is only for the refs, i.e. you will only
234include refs and commits reachable from those refs. You will not
235include other local state, such as the contents of the index, working
236tree, the stash, per-repository configuration, hooks, etc.
237
238You can later recover that repository by using for example
239linkgit:git-clone[1]:
240
241----------------
242$ git clone backup.bundle <new directory>
243----------------
244
245For the next example, assume you want to transfer the history from a
246repository R1 on machine A to another repository R2 on machine B.
247For whatever reason, direct connection between A and B is not allowed,
248but we can move data from A to B via some mechanism (CD, email, etc.).
249We want to update R2 with development made on the branch master in R1.
250
251To bootstrap the process, you can first create a bundle that does not have
252any prerequisites. You can use a tag to remember up to what commit you last
253processed, in order to make it easy to later update the other repository
254with an incremental bundle:
255
256----------------
257machineA$ cd R1
258machineA$ git bundle create file.bundle master
259machineA$ git tag -f lastR2bundle master
260----------------
261
262Then you transfer file.bundle to the target machine B. Because this
263bundle does not require any existing object to be extracted, you can
264create a new repository on machine B by cloning from it:
265
266----------------
267machineB$ git clone -b master /home/me/tmp/file.bundle R2
268----------------
269
270This will define a remote called "origin" in the resulting repository that
271lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
272have an entry like this:
273
274------------------------
275[remote "origin"]
276 url = /home/me/tmp/file.bundle
277 fetch = refs/heads/*:refs/remotes/origin/*
278------------------------
279
280To update the resulting mine.git repository, you can fetch or pull after
281replacing the bundle stored at /home/me/tmp/file.bundle with incremental
282updates.
283
284After working some more in the original repository, you can create an
285incremental bundle to update the other repository:
286
287----------------
288machineA$ cd R1
289machineA$ git bundle create file.bundle lastR2bundle..master
290machineA$ git tag -f lastR2bundle master
291----------------
292
293You then transfer the bundle to the other machine to replace
294/home/me/tmp/file.bundle, and pull from it.
295
296----------------
297machineB$ cd R2
298machineB$ git pull
299----------------
300
301If you know up to what commit the intended recipient repository should
302have the necessary objects, you can use that knowledge to specify the
303prerequisites, giving a cut-off point to limit the revisions and objects that go
304in the resulting bundle. The previous example used the lastR2bundle tag
305for this purpose, but you can use any other options that you would give to
306the linkgit:git-log[1] command. Here are more examples:
307
308You can use a tag that is present in both:
309
310----------------
311$ git bundle create mybundle v1.0.0..master
312----------------
313
314You can use a prerequisite based on time:
315
316----------------
317$ git bundle create mybundle --since=10.days master
318----------------
319
320You can use the number of commits:
321
322----------------
323$ git bundle create mybundle -10 master
324----------------
325
326You can run `git-bundle verify` to see if you can extract from a bundle
327that was created with a prerequisite:
328
329----------------
330$ git bundle verify mybundle
331----------------
332
333This will list what commits you must have in order to extract from the
334bundle and will error out if you do not have them.
335
336A bundle from a recipient repository's point of view is just like a
337regular repository which it fetches or pulls from. You can, for example, map
338references when fetching:
339
340----------------
341$ git fetch mybundle master:localRef
342----------------
343
344You can also see what references it offers:
345
346----------------
347$ git ls-remote mybundle
348----------------
349
350DISCUSSION
351----------
352
353A naive way to make a full backup of a repository is to use something to
354the effect of `cp -r <repo> <destination>`. This is discouraged since
355the repository could be written to during the copy operation. In turn
356some files at `<destination>` could be corrupted.
357
358This is why it is recommended to use Git tooling for making repository
359backups, either with this command or with e.g. linkgit:git-clone[1].
360But keep in mind that these tools will not help you backup state other
361than refs and commits. In other words they will not help you backup
362contents of the index, working tree, the stash, per-repository
363configuration, hooks, etc.
364
365See also linkgit:gitfaq[7], section "TRANSFERS" for a discussion of the
366problems associated with file syncing across systems.
367
368FILE FORMAT
369-----------
370
371See linkgit:gitformat-bundle[5].
372
373GIT
374---
375Part of the linkgit:git[1] suite