Skip to content

Commit c515230

Browse files
committed
Merge branch 'kh/bundle-docs'
Documentation for "git bundle" saw improvements to more prominently call out the use of '--all' when creating bundles. * kh/bundle-docs: Documentation/git-bundle.txt: discuss naïve backups Documentation/git-bundle.txt: mention --all in spec. refs Documentation/git-bundle.txt: remove old `--all` example Documentation/git-bundle.txt: mention full backup example
2 parents 6ea2d9d + 820fd1a commit c515230

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

Documentation/git-bundle.txt

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ the "offline" transfer of Git objects without an active "server"
2323
sitting on the other side of the network connection.
2424

2525
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.
26+
repository (see the "full backup" example in "EXAMPLES"), and to relay
27+
the state of the references in one repository to another (see the second
28+
example).
2829

2930
Git commands that fetch or otherwise "read" via protocols such as
3031
`ssh://` and `https://` can also operate on bundle files. It is
@@ -34,8 +35,6 @@ contained within it with linkgit:git-ls-remote[1]. There's no
3435
corresponding "write" support, i.e.a 'git push' into a bundle is not
3536
supported.
3637

37-
See the "EXAMPLES" section below for examples of how to use bundles.
38-
3938
BUNDLE FORMAT
4039
-------------
4140

@@ -132,7 +131,7 @@ SPECIFYING REFERENCES
132131
---------------------
133132

134133
Revisions must be accompanied by reference names to be packaged in a
135-
bundle.
134+
bundle. Alternatively `--all` can be used to package all refs.
136135

137136
More than one reference may be packaged, and more than one set of prerequisite objects can
138137
be specified. The objects packaged are those not contained in the
@@ -203,8 +202,6 @@ It is okay to err on the side of caution, causing the bundle file
203202
to contain objects already in the destination, as these are ignored
204203
when unpacking at the destination.
205204

206-
If you want to match `git clone --mirror`, which would include your
207-
refs such as `refs/remotes/*`, use `--all`.
208205
If you want to provide the same set of refs that a clone directly
209206
from the source repository would get, use `--branches --tags` for
210207
the `<git-rev-list-args>`.
@@ -216,8 +213,34 @@ bundle.
216213
EXAMPLES
217214
--------
218215

219-
Assume you want to transfer the history from a repository R1 on machine A
220-
to another repository R2 on machine B.
216+
We'll discuss two cases:
217+
218+
1. Taking a full backup of a repository
219+
2. Transferring the history of a repository to another machine when the
220+
two machines have no direct connection
221+
222+
First let's consider a full backup of the repository. The following
223+
command will take a full backup of the repository in the sense that all
224+
refs are included in the bundle:
225+
226+
----------------
227+
$ git bundle create backup.bundle --all
228+
----------------
229+
230+
But note again that this is only for the refs, i.e. you will only
231+
include refs and commits reachable from those refs. You will not
232+
include other local state, such as the contents of the index, working
233+
tree, the stash, per-repository configuration, hooks, etc.
234+
235+
You can later recover that repository by using for example
236+
linkgit:git-clone[1]:
237+
238+
----------------
239+
$ git clone backup.bundle <new directory>
240+
----------------
241+
242+
For the next example, assume you want to transfer the history from a
243+
repository R1 on machine A to another repository R2 on machine B.
221244
For whatever reason, direct connection between A and B is not allowed,
222245
but we can move data from A to B via some mechanism (CD, email, etc.).
223246
We want to update R2 with development made on the branch master in R1.
@@ -321,6 +344,24 @@ You can also see what references it offers:
321344
$ git ls-remote mybundle
322345
----------------
323346

347+
DISCUSSION
348+
----------
349+
350+
A naive way to make a full backup of a repository is to use something to
351+
the effect of `cp -r <repo> <destination>`. This is discouraged since
352+
the repository could be written to during the copy operation. In turn
353+
some files at `<destination>` could be corrupted.
354+
355+
This is why it is recommended to use Git tooling for making repository
356+
backups, either with this command or with e.g. linkgit:git-clone[1].
357+
But keep in mind that these tools will not help you backup state other
358+
than refs and commits. In other words they will not help you backup
359+
contents of the index, working tree, the stash, per-repository
360+
configuration, hooks, etc.
361+
362+
See also linkgit:gitfaq[7], section "TRANSFERS" for a discussion of the
363+
problems associated with file syncing across systems.
364+
324365
FILE FORMAT
325366
-----------
326367

0 commit comments

Comments
 (0)