Skip to content

Commit f19b275

Browse files
committed
Merge branch 'ab/bundle-doc'
Doc update. * ab/bundle-doc: bundle doc: replace "basis" with "prerequsite(s)" bundle doc: elaborate on rev<->ref restriction bundle doc: elaborate on object prerequisites bundle doc: rewrite the "DESCRIPTION" section
2 parents bda891e + 1d9c8da commit f19b275

File tree

1 file changed

+117
-30
lines changed

1 file changed

+117
-30
lines changed

Documentation/git-bundle.txt

Lines changed: 117 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,48 @@ SYNOPSIS
1818
DESCRIPTION
1919
-----------
2020

21-
Some workflows require that one or more branches of development on one
22-
machine be replicated on another machine, but the two machines cannot
23-
be directly connected, and therefore the interactive Git protocols (git,
24-
ssh, http) cannot be used.
25-
26-
The 'git bundle' command packages objects and references in an archive
27-
at the originating machine, which can then be imported into another
28-
repository using 'git fetch', 'git pull', or 'git clone',
29-
after moving the archive by some means (e.g., by sneakernet).
30-
31-
As no
32-
direct connection between the repositories exists, the user must specify a
33-
basis for the bundle that is held by the destination repository: the
34-
bundle assumes that all objects in the basis are already in the
35-
destination repository.
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.
24+
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
27+
to another.
28+
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
35+
supported.
36+
37+
See the "EXAMPLES" section below for examples of how to use bundles.
38+
39+
BUNDLE FORMAT
40+
-------------
41+
42+
Bundles are `.pack` files (see linkgit:git-pack-objects[1]) with a
43+
header indicating what references are contained within the bundle.
44+
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.
48+
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].
52+
53+
There is no option to create a "thick pack" when using revision
54+
exclusions, 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
58+
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
62+
further details.
3663

3764
OPTIONS
3865
-------
@@ -117,28 +144,88 @@ unbundle <file>::
117144
SPECIFYING REFERENCES
118145
---------------------
119146

120-
'git bundle' will only package references that are shown by
121-
'git show-ref': this includes heads, tags, and remote heads. References
122-
such as `master~1` cannot be packaged, but are perfectly suitable for
123-
defining the basis. More than one reference may be packaged, and more
124-
than one basis can be specified. The objects packaged are those not
125-
contained in the union of the given bases. Each basis can be
126-
specified explicitly (e.g. `^master~10`), or implicitly (e.g.
127-
`master~10..master`, `--since=10.days.ago master`).
147+
Revisions must accompanied by reference names to be packaged in a
148+
bundle.
149+
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.
153+
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`).
158+
159+
All of these simple cases are OK (assuming we have a "master" and
160+
"next" branch):
161+
162+
----------------
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
167+
----------------
168+
169+
And so are these (and the same but omitted `--stdin` examples):
170+
171+
----------------
172+
$ git bundle create recent-master.bundle master~10..master
173+
$ git bundle create recent-updates.bundle master~10..master next~5..next
174+
----------------
175+
176+
A revision name or a range whose right-hand-side cannot be resolved to
177+
a reference is not accepted:
178+
179+
----------------
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.
184+
----------------
185+
186+
OBJECT PREREQUISITES
187+
--------------------
188+
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.
193+
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`:
198+
199+
----------------
200+
$ git bundle create full.bundle new
201+
----------------
202+
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:
206+
207+
----------------
208+
$ git bundle create full.bundle old..new
209+
----------------
210+
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`).
128214

129-
It is very important that the basis used be held by the destination.
130215
It is okay to err on the side of caution, causing the bundle file
131216
to contain objects already in the destination, as these are ignored
132217
when unpacking at the destination.
133218

134-
`git clone` can use any bundle created without negative refspecs
135-
(e.g., `new`, but not `old..new`).
136219
If you want to match `git clone --mirror`, which would include your
137220
refs such as `refs/remotes/*`, use `--all`.
138221
If you want to provide the same set of refs that a clone directly
139222
from the source repository would get, use `--branches --tags` for
140223
the `<git-rev-list-args>`.
141224

225+
The 'git bundle verify' command can be used to check whether your
226+
recipient repository has the required prerequisite commits for a
227+
bundle.
228+
142229
EXAMPLES
143230
--------
144231

@@ -149,7 +236,7 @@ but we can move data from A to B via some mechanism (CD, email, etc.).
149236
We want to update R2 with development made on the branch master in R1.
150237

151238
To bootstrap the process, you can first create a bundle that does not have
152-
any basis. You can use a tag to remember up to what commit you last
239+
any prerequisites. You can use a tag to remember up to what commit you last
153240
processed, in order to make it easy to later update the other repository
154241
with an incremental bundle:
155242

@@ -200,7 +287,7 @@ machineB$ git pull
200287

201288
If you know up to what commit the intended recipient repository should
202289
have the necessary objects, you can use that knowledge to specify the
203-
basis, giving a cut-off point to limit the revisions and objects that go
290+
prerequisites, giving a cut-off point to limit the revisions and objects that go
204291
in the resulting bundle. The previous example used the lastR2bundle tag
205292
for this purpose, but you can use any other options that you would give to
206293
the linkgit:git-log[1] command. Here are more examples:
@@ -211,7 +298,7 @@ You can use a tag that is present in both:
211298
$ git bundle create mybundle v1.0.0..master
212299
----------------
213300

214-
You can use a basis based on time:
301+
You can use a prerequisite based on time:
215302

216303
----------------
217304
$ git bundle create mybundle --since=10.days master
@@ -224,7 +311,7 @@ $ git bundle create mybundle -10 master
224311
----------------
225312

226313
You can run `git-bundle verify` to see if you can extract from a bundle
227-
that was created with a basis:
314+
that was created with a prerequisite:
228315

229316
----------------
230317
$ git bundle verify mybundle

0 commit comments

Comments
 (0)