blob: 3ab42a19cae4aca0e6a3a83db92d25a4d88bf927 [file] [log] [blame]
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +01001git-bundle(1)
2=============
3
4NAME
5----
6git-bundle - Move objects and refs by archive
7
8
9SYNOPSIS
10--------
Matthias Kestenholze448ff82007-05-18 15:39:33 +020011[verse]
Jeff King8b955212023-03-04 05:55:13 -050012'git bundle' create [-q | --quiet | --progress]
brian m. carlsonc5aecfc2020-07-29 23:14:20 +000013 [--version=<version>] <file> <git-rev-list-args>
Robin H. Johnsone0eba642019-11-10 12:41:26 -080014'git bundle' verify [-q | --quiet] <file>
Štěpán Němec62b46982010-10-08 19:31:15 +020015'git bundle' list-heads <file> [<refname>...]
Ævar Arnfjörð Bjarmasond941cc42021-09-05 09:34:45 +020016'git bundle' unbundle [--progress] <file> [<refname>...]
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +010017
18DESCRIPTION
19-----------
20
Ævar Arnfjörð Bjarmason5c8273d2021-07-31 10:23:04 +020021Create, 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.
Philip Oakley0e40a732019-10-20 12:03:06 +010024
Ævar Arnfjörð Bjarmason5c8273d2021-07-31 10:23:04 +020025They can be used to create both incremental and full backups of a
26repository, and to relay the state of the references in one repository
27to another.
Philip Oakley0e40a732019-10-20 12:03:06 +010028
Ævar Arnfjörð Bjarmason5c8273d2021-07-31 10:23:04 +020029Git commands that fetch or otherwise "read" via protocols such as
30`ssh://` and `https://` can also operate on bundle files. It is
31possible linkgit:git-clone[1] a new repository from a bundle, to use
32linkgit:git-fetch[1] to fetch from one, and to list the references
33contained within it with linkgit:git-ls-remote[1]. There's no
34corresponding "write" support, i.e.a 'git push' into a bundle is not
35supported.
36
37See the "EXAMPLES" section below for examples of how to use bundles.
38
39BUNDLE FORMAT
40-------------
41
42Bundles are `.pack` files (see linkgit:git-pack-objects[1]) with a
43header indicating what references are contained within the bundle.
44
Jacob Stopakc9dba102022-09-11 03:23:20 -070045Like the packed archive format itself bundles can either be
Ævar Arnfjörð Bjarmason5c8273d2021-07-31 10:23:04 +020046self-contained, or be created using exclusions.
Ævar Arnfjörð Bjarmason9ab80dd2021-07-31 10:23:05 +020047See the "OBJECT PREREQUISITES" section below.
Ævar Arnfjörð Bjarmason5c8273d2021-07-31 10:23:04 +020048
49Bundles created using revision exclusions are "thin packs" created
50using the `--thin` option to linkgit:git-pack-objects[1], and
51unbundled using the `--fix-thin` option to linkgit:git-index-pack[1].
52
53There is no option to create a "thick pack" when using revision
Martin Ågrena4dfb442021-10-24 19:08:21 +020054exclusions, and users should not be concerned about the difference. By
55using "thin packs", bundles created using exclusions are smaller in
Ævar Arnfjörð Bjarmason5c8273d2021-07-31 10:23:04 +020056size. That they're "thin" under the hood is merely noted here as a
Martin Ågrena4dfb442021-10-24 19:08:21 +020057curiosity, and as a reference to other documentation.
Ævar Arnfjörð Bjarmason5c8273d2021-07-31 10:23:04 +020058
Ævar Arnfjörð Bjarmason844739b2022-08-04 18:28:34 +020059See linkgit:gitformat-bundle[5] for more details and the discussion of
Ævar Arnfjörð Bjarmason977c47b2022-08-04 18:28:39 +020060"thin pack" in linkgit:gitformat-pack[5] for further details.
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +010061
62OPTIONS
63-------
64
Robin H. Johnson79862b62019-11-10 12:41:25 -080065create [options] <file> <git-rev-list-args>::
Michael J Grubera6190562010-08-23 11:02:38 +020066 Used to create a bundle named 'file'. This requires the
Philip Oakley0e40a732019-10-20 12:03:06 +010067 '<git-rev-list-args>' arguments to define the bundle contents.
Robin H. Johnson79862b62019-11-10 12:41:25 -080068 'options' contains the options specific to the 'git bundle create'
Jeff Kingef3b2912023-03-04 05:26:40 -050069 subcommand. If 'file' is `-`, the bundle is written to stdout.
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +010070
71verify <file>::
Michael J Grubera6190562010-08-23 11:02:38 +020072 Used to check that a bundle file is valid and will apply
73 cleanly to the current repository. This includes checks on the
74 bundle format itself as well as checking that the prerequisite
75 commits exist and are fully linked in the current repository.
Derrick Stolee017303e2022-03-22 17:28:38 +000076 Then, 'git bundle' prints a list of missing commits, if any.
77 Finally, information about additional capabilities, such as "object
Ævar Arnfjörð Bjarmason844739b2022-08-04 18:28:34 +020078 filter", is printed. See "Capabilities" in linkgit:gitformat-bundle[5]
Derrick Stolee017303e2022-03-22 17:28:38 +000079 for more information. The exit code is zero for success, but will
Jeff Kingef3b2912023-03-04 05:26:40 -050080 be nonzero if the bundle file is invalid. If 'file' is `-`, the
81 bundle is read from stdin.
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +010082
83list-heads <file>::
Michael J Grubera6190562010-08-23 11:02:38 +020084 Lists the references defined in the bundle. If followed by a
85 list of references, only references matching those given are
Jeff Kingef3b2912023-03-04 05:26:40 -050086 printed out. If 'file' is `-`, the bundle is read from stdin.
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +010087
88unbundle <file>::
Michael J Grubera6190562010-08-23 11:02:38 +020089 Passes the objects in the bundle to 'git index-pack'
90 for storage in the repository, then prints the names of all
91 defined references. If a list of references is given, only
92 references matching those in the list are printed. This command is
93 really plumbing, intended to be called only by 'git fetch'.
Jeff Kingef3b2912023-03-04 05:26:40 -050094 If 'file' is `-`, the bundle is read from stdin.
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +010095
Michael J Gruber5e1f9602010-08-23 11:02:37 +020096<git-rev-list-args>::
Michael J Grubera6190562010-08-23 11:02:38 +020097 A list of arguments, acceptable to 'git rev-parse' and
Ralf Wildenhues469bfc92011-01-03 20:03:34 +010098 'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES
Michael J Gruber1884df12010-08-23 11:02:39 +020099 below), that specifies the specific objects and references
Jeff King6cf378f2012-04-26 04:51:57 -0400100 to transport. For example, `master~10..master` causes the
Michael J Grubera6190562010-08-23 11:02:38 +0200101 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.
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100105
106
Štěpán Němec62b46982010-10-08 19:31:15 +0200107[<refname>...]::
Michael J Grubera6190562010-08-23 11:02:38 +0200108 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').
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100113
Robin H. Johnson79862b62019-11-10 12:41:25 -0800114--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
brian m. carlsonc5aecfc2020-07-29 23:14:20 +0000120--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
Robin H. Johnson79862b62019-11-10 12:41:25 -0800126-q::
127--quiet::
128 This flag makes the command not to report its progress
129 on the standard error stream.
130
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100131SPECIFYING REFERENCES
132---------------------
133
Martin Ågrena4dfb442021-10-24 19:08:21 +0200134Revisions must be accompanied by reference names to be packaged in a
Ævar Arnfjörð Bjarmason0bb92f32021-07-31 10:23:06 +0200135bundle.
136
Ævar Arnfjörð Bjarmason1d9c8da2021-07-31 10:23:07 +0200137More than one reference may be packaged, and more than one set of prerequisite objects can
Ævar Arnfjörð Bjarmason0bb92f32021-07-31 10:23:06 +0200138be specified. The objects packaged are those not contained in the
Ævar Arnfjörð Bjarmason1d9c8da2021-07-31 10:23:07 +0200139union of the prerequisites.
Ævar Arnfjörð Bjarmason0bb92f32021-07-31 10:23:06 +0200140
141The 'git bundle create' command resolves the reference names for you
142using the same rules as `git rev-parse --abbrev-ref=loose`. Each
Ævar Arnfjörð Bjarmason1d9c8da2021-07-31 10:23:07 +0200143prerequisite can be specified explicitly (e.g. `^master~10`), or implicitly
Ævar Arnfjörð Bjarmason0bb92f32021-07-31 10:23:06 +0200144(e.g. `master~10..master`, `--since=10.days.ago master`).
145
146All of these simple cases are OK (assuming we have a "master" and
147"next" branch):
148
149----------------
150$ git bundle create master.bundle master
151$ echo master | git bundle create master.bundle --stdin
152$ git bundle create master-and-next.bundle master next
153$ (echo master; echo next) | git bundle create master-and-next.bundle --stdin
154----------------
155
156And so are these (and the same but omitted `--stdin` examples):
157
158----------------
159$ git bundle create recent-master.bundle master~10..master
160$ git bundle create recent-updates.bundle master~10..master next~5..next
161----------------
162
163A revision name or a range whose right-hand-side cannot be resolved to
164a reference is not accepted:
165
166----------------
167$ git bundle create HEAD.bundle $(git rev-parse HEAD)
168fatal: Refusing to create empty bundle.
169$ git bundle create master-yesterday.bundle master~10..master~5
170fatal: Refusing to create empty bundle.
171----------------
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100172
Ævar Arnfjörð Bjarmason9ab80dd2021-07-31 10:23:05 +0200173OBJECT PREREQUISITES
174--------------------
175
176When creating bundles it is possible to create a self-contained bundle
177that can be unbundled in a repository with no common history, as well
178as providing negative revisions to exclude objects needed in the
179earlier parts of the history.
180
181Feeding a revision such as `new` to `git bundle create` will create a
182bundle file that contains all the objects reachable from the revision
183`new`. That bundle can be unbundled in any repository to obtain a full
184history that leads to the revision `new`:
185
186----------------
187$ git bundle create full.bundle new
188----------------
189
190A revision range such as `old..new` will produce a bundle file that
191will require the revision `old` (and any objects reachable from it)
192to exist for the bundle to be "unbundle"-able:
193
194----------------
195$ git bundle create full.bundle old..new
196----------------
197
198A self-contained bundle without any prerequisites can be extracted
199into anywhere, even into an empty repository, or be cloned from
200(i.e., `new`, but not `old..new`).
201
David J. Mellor1d52b022009-03-22 18:00:14 -0700202It is okay to err on the side of caution, causing the bundle file
203to contain objects already in the destination, as these are ignored
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100204when unpacking at the destination.
205
Philip Oakley0e40a732019-10-20 12:03:06 +0100206If you want to match `git clone --mirror`, which would include your
207refs such as `refs/remotes/*`, use `--all`.
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
Ævar Arnfjörð Bjarmason9ab80dd2021-07-31 10:23:05 +0200212The 'git bundle verify' command can be used to check whether your
213recipient repository has the required prerequisite commits for a
214bundle.
215
Nguyễn Thái Ngọc Duy76a87882018-04-30 17:35:33 +0200216EXAMPLES
217--------
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100218
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900219Assume you want to transfer the history from a repository R1 on machine A
220to another repository R2 on machine B.
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100221For whatever reason, direct connection between A and B is not allowed,
David J. Mellor1d52b022009-03-22 18:00:14 -0700222but we can move data from A to B via some mechanism (CD, email, etc.).
223We want to update R2 with development made on the branch master in R1.
Santi Béjar99d8ea22008-02-24 14:42:40 +0100224
David J. Mellor1d52b022009-03-22 18:00:14 -0700225To bootstrap the process, you can first create a bundle that does not have
Ævar Arnfjörð Bjarmason1d9c8da2021-07-31 10:23:07 +0200226any prerequisites. You can use a tag to remember up to what commit you last
David J. Mellor1d52b022009-03-22 18:00:14 -0700227processed, in order to make it easy to later update the other repository
228with an incremental bundle:
Santi Béjar99d8ea22008-02-24 14:42:40 +0100229
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900230----------------
231machineA$ cd R1
Santi Béjarffe4da12009-02-07 23:21:49 +0100232machineA$ git bundle create file.bundle master
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900233machineA$ git tag -f lastR2bundle master
234----------------
Santi Béjar99d8ea22008-02-24 14:42:40 +0100235
Junio C Hamanob5fb4772013-01-01 12:46:15 -0800236Then you transfer file.bundle to the target machine B. Because this
237bundle does not require any existing object to be extracted, you can
238create a new repository on machine B by cloning from it:
Santi Béjar99d8ea22008-02-24 14:42:40 +0100239
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900240----------------
Kirill Brilliantovded6aa62013-01-01 17:54:44 +0400241machineB$ git clone -b master /home/me/tmp/file.bundle R2
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900242----------------
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100243
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900244This will define a remote called "origin" in the resulting repository that
David J. Mellor1d52b022009-03-22 18:00:14 -0700245lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900246have an entry like this:
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100247
Santi Béjar99d8ea22008-02-24 14:42:40 +0100248------------------------
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900249[remote "origin"]
Santi Béjarffe4da12009-02-07 23:21:49 +0100250 url = /home/me/tmp/file.bundle
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100251 fetch = refs/heads/*:refs/remotes/origin/*
Santi Béjar99d8ea22008-02-24 14:42:40 +0100252------------------------
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100253
David J. Mellor1d52b022009-03-22 18:00:14 -0700254To update the resulting mine.git repository, you can fetch or pull after
255replacing the bundle stored at /home/me/tmp/file.bundle with incremental
256updates.
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100257
David J. Mellor1d52b022009-03-22 18:00:14 -0700258After working some more in the original repository, you can create an
259incremental bundle to update the other repository:
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100260
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900261----------------
262machineA$ cd R1
Santi Béjarffe4da12009-02-07 23:21:49 +0100263machineA$ git bundle create file.bundle lastR2bundle..master
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900264machineA$ git tag -f lastR2bundle master
265----------------
266
David J. Mellor1d52b022009-03-22 18:00:14 -0700267You then transfer the bundle to the other machine to replace
268/home/me/tmp/file.bundle, and pull from it.
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900269
270----------------
271machineB$ cd R2
272machineB$ git pull
273----------------
274
275If you know up to what commit the intended recipient repository should
David J. Mellor1d52b022009-03-22 18:00:14 -0700276have the necessary objects, you can use that knowledge to specify the
Ævar Arnfjörð Bjarmason1d9c8da2021-07-31 10:23:07 +0200277prerequisites, giving a cut-off point to limit the revisions and objects that go
Michael J Gruber5e1f9602010-08-23 11:02:37 +0200278in the resulting bundle. The previous example used the lastR2bundle tag
David J. Mellor1d52b022009-03-22 18:00:14 -0700279for this purpose, but you can use any other options that you would give to
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900280the linkgit:git-log[1] command. Here are more examples:
281
David J. Mellor1d52b022009-03-22 18:00:14 -0700282You can use a tag that is present in both:
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900283
284----------------
285$ git bundle create mybundle v1.0.0..master
286----------------
287
Ævar Arnfjörð Bjarmason1d9c8da2021-07-31 10:23:07 +0200288You can use a prerequisite based on time:
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900289
290----------------
291$ git bundle create mybundle --since=10.days master
292----------------
293
David J. Mellor1d52b022009-03-22 18:00:14 -0700294You can use the number of commits:
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900295
296----------------
297$ git bundle create mybundle -10 master
298----------------
299
300You can run `git-bundle verify` to see if you can extract from a bundle
Ævar Arnfjörð Bjarmason1d9c8da2021-07-31 10:23:07 +0200301that was created with a prerequisite:
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900302
303----------------
304$ git bundle verify mybundle
305----------------
306
307This will list what commits you must have in order to extract from the
David J. Mellor1d52b022009-03-22 18:00:14 -0700308bundle and will error out if you do not have them.
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900309
310A bundle from a recipient repository's point of view is just like a
David J. Mellor1d52b022009-03-22 18:00:14 -0700311regular repository which it fetches or pulls from. You can, for example, map
312references when fetching:
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900313
314----------------
315$ git fetch mybundle master:localRef
316----------------
317
Michael J Gruber5e1f9602010-08-23 11:02:37 +0200318You can also see what references it offers:
Nanako Shiraishi8aa7eeb2009-02-04 18:15:29 +0900319
320----------------
321$ git ls-remote mybundle
322----------------
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100323
Ævar Arnfjörð Bjarmason844739b2022-08-04 18:28:34 +0200324FILE FORMAT
325-----------
326
327See linkgit:gitformat-bundle[5].
328
Johannes Schindelin2e0afaf2007-02-22 01:59:14 +0100329GIT
330---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200331Part of the linkgit:git[1] suite