blob: 3ab42a19cae4aca0e6a3a83db92d25a4d88bf927 [file] [log] [blame]
Junio C Hamano6ac2f142007-03-01 01:24:561git-bundle(1)
2=============
3
4NAME
5----
6git-bundle - Move objects and refs by archive
7
8
9SYNOPSIS
10--------
Junio C Hamanoa9b8d242007-05-19 04:51:5511[verse]
Junio C Hamano3f5b4a72023-03-19 22:19:0312'git bundle' create [-q | --quiet | --progress]
Junio C Hamanoc425d102020-08-12 01:44:2413 [--version=<version>] <file> <git-rev-list-args>
Junio C Hamano8ef91f32019-12-01 22:58:2714'git bundle' verify [-q | --quiet] <file>
Junio C Hamanod2179ef2010-10-22 04:12:1715'git bundle' list-heads <file> [<refname>...]
Junio C Hamanode44de32021-09-20 22:46:0816'git bundle' unbundle [--progress] <file> [<refname>...]
Junio C Hamano6ac2f142007-03-01 01:24:5617
18DESCRIPTION
19-----------
20
Junio C Hamanod2e30562021-08-24 23:21:5121Create, 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.
Junio C Hamanob4896852019-12-10 23:15:0924
Junio C Hamanod2e30562021-08-24 23:21:5125They 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.
Junio C Hamanob4896852019-12-10 23:15:0928
Junio C Hamanod2e30562021-08-24 23:21:5129Git 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
Junio C Hamano3778ccc2022-09-15 23:33:1745Like the packed archive format itself bundles can either be
Junio C Hamanod2e30562021-08-24 23:21:5146self-contained, or be created using exclusions.
47See the "OBJECT PREREQUISITES" section below.
48
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
Junio C Hamano19dcd3f2021-10-29 23:20:4754exclusions, and users should not be concerned about the difference. By
55using "thin packs", bundles created using exclusions are smaller in
Junio C Hamanod2e30562021-08-24 23:21:5156size. That they're "thin" under the hood is merely noted here as a
Junio C Hamano19dcd3f2021-10-29 23:20:4757curiosity, and as a reference to other documentation.
Junio C Hamanod2e30562021-08-24 23:21:5158
Junio C Hamano04495a12022-08-18 21:13:0859See linkgit:gitformat-bundle[5] for more details and the discussion of
60"thin pack" in linkgit:gitformat-pack[5] for further details.
Junio C Hamano6ac2f142007-03-01 01:24:5661
62OPTIONS
63-------
64
Junio C Hamano8ef91f32019-12-01 22:58:2765create [options] <file> <git-rev-list-args>::
Junio C Hamano2db3e752010-09-03 21:33:0666Used to create a bundle named 'file'. This requires the
Junio C Hamanob4896852019-12-10 23:15:0967'<git-rev-list-args>' arguments to define the bundle contents.
Junio C Hamano8ef91f32019-12-01 22:58:2768'options' contains the options specific to the 'git bundle create'
Junio C Hamano3f5b4a72023-03-19 22:19:0369subcommand. If 'file' is `-`, the bundle is written to stdout.
Junio C Hamano6ac2f142007-03-01 01:24:5670
71verify <file>::
Junio C Hamano2db3e752010-09-03 21:33:0672Used to check that a bundle file is valid and will apply
73cleanly to the current repository. This includes checks on the
74bundle format itself as well as checking that the prerequisite
75commits exist and are fully linked in the current repository.
Junio C Hamano4bea0282022-04-04 18:21:4976Then, 'git bundle' prints a list of missing commits, if any.
77Finally, information about additional capabilities, such as "object
Junio C Hamano04495a12022-08-18 21:13:0878filter", is printed. See "Capabilities" in linkgit:gitformat-bundle[5]
Junio C Hamano4bea0282022-04-04 18:21:4979for more information. The exit code is zero for success, but will
Junio C Hamano3f5b4a72023-03-19 22:19:0380be nonzero if the bundle file is invalid. If 'file' is `-`, the
81bundle is read from stdin.
Junio C Hamano6ac2f142007-03-01 01:24:5682
83list-heads <file>::
Junio C Hamano2db3e752010-09-03 21:33:0684Lists the references defined in the bundle. If followed by a
85list of references, only references matching those given are
Junio C Hamano3f5b4a72023-03-19 22:19:0386printed out. If 'file' is `-`, the bundle is read from stdin.
Junio C Hamano6ac2f142007-03-01 01:24:5687
88unbundle <file>::
Junio C Hamano2db3e752010-09-03 21:33:0689Passes the objects in the bundle to 'git index-pack'
90for storage in the repository, then prints the names of all
91defined references. If a list of references is given, only
92references matching those in the list are printed. This command is
93really plumbing, intended to be called only by 'git fetch'.
Junio C Hamano3f5b4a72023-03-19 22:19:0394If 'file' is `-`, the bundle is read from stdin.
Junio C Hamano6ac2f142007-03-01 01:24:5695
Junio C Hamano2db3e752010-09-03 21:33:0696<git-rev-list-args>::
97A list of arguments, acceptable to 'git rev-parse' and
Junio C Hamano7165bf72011-01-04 22:06:1898'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES
Junio C Hamano2db3e752010-09-03 21:33:0699below), that specifies the specific objects and references
Junio C Hamanob76a6862012-05-02 22:02:46100to transport. For example, `master~10..master` causes the
Junio C Hamano2db3e752010-09-03 21:33:06101current master reference to be packaged along with all objects
102added since its 10th ancestor commit. There is no explicit
103limit to the number of references and objects that may be
104packaged.
Junio C Hamano6ac2f142007-03-01 01:24:56105
106
Junio C Hamanod2179ef2010-10-22 04:12:17107[<refname>...]::
Junio C Hamano2db3e752010-09-03 21:33:06108A list of references used to limit the references reported as
109available. This is principally of use to 'git fetch', which
110expects to receive only those references asked for and not
111necessarily everything in the pack (in this case, 'git bundle' acts
112like 'git fetch-pack').
Junio C Hamano6ac2f142007-03-01 01:24:56113
Junio C Hamano8ef91f32019-12-01 22:58:27114--progress::
115Progress status is reported on the standard error stream
116by default when it is attached to a terminal, unless -q
117is specified. This flag forces progress status even if
118the standard error stream is not directed to a terminal.
119
Junio C Hamanoc425d102020-08-12 01:44:24120--version=<version>::
121Specify the bundle version. Version 2 is the older format and can only be
122used with SHA-1 repositories; the newer version 3 contains capabilities that
123permit extensions. The default is the oldest supported format, based on the
124hash algorithm in use.
125
Junio C Hamano8ef91f32019-12-01 22:58:27126-q::
127--quiet::
128This flag makes the command not to report its progress
129on the standard error stream.
130
Junio C Hamano6ac2f142007-03-01 01:24:56131SPECIFYING REFERENCES
132---------------------
133
Junio C Hamano19dcd3f2021-10-29 23:20:47134Revisions must be accompanied by reference names to be packaged in a
Junio C Hamanod2e30562021-08-24 23:21:51135bundle.
Junio C Hamano6ac2f142007-03-01 01:24:56136
Junio C Hamanod2e30562021-08-24 23:21:51137More than one reference may be packaged, and more than one set of prerequisite objects can
138be specified. The objects packaged are those not contained in the
139union of the prerequisites.
140
141The 'git bundle create' command resolves the reference names for you
142using the same rules as `git rev-parse --abbrev-ref=loose`. Each
143prerequisite can be specified explicitly (e.g. `^master~10`), or implicitly
144(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----------------
172
173OBJECT 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
Junio C Hamano1de75722009-03-26 08:39:38202It is okay to err on the side of caution, causing the bundle file
203to contain objects already in the destination, as these are ignored
Junio C Hamano6ac2f142007-03-01 01:24:56204when unpacking at the destination.
205
Junio C Hamanob4896852019-12-10 23:15:09206If 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
Junio C Hamanod2e30562021-08-24 23:21:51212The 'git bundle verify' command can be used to check whether your
213recipient repository has the required prerequisite commits for a
214bundle.
215
Junio C Hamanob9d9d902018-05-23 07:07:42216EXAMPLES
217--------
Junio C Hamano6ac2f142007-03-01 01:24:56218
Junio C Hamanoa3bb6eb2009-02-05 01:26:33219Assume you want to transfer the history from a repository R1 on machine A
220to another repository R2 on machine B.
Junio C Hamano6ac2f142007-03-01 01:24:56221For whatever reason, direct connection between A and B is not allowed,
Junio C Hamano1de75722009-03-26 08:39:38222but 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.
Junio C Hamano601f3e52008-02-25 08:40:42224
Junio C Hamano1de75722009-03-26 08:39:38225To bootstrap the process, you can first create a bundle that does not have
Junio C Hamanod2e30562021-08-24 23:21:51226any prerequisites. You can use a tag to remember up to what commit you last
Junio C Hamano1de75722009-03-26 08:39:38227processed, in order to make it easy to later update the other repository
228with an incremental bundle:
Junio C Hamano601f3e52008-02-25 08:40:42229
Junio C Hamanoa3bb6eb2009-02-05 01:26:33230----------------
231machineA$ cd R1
Junio C Hamano61169122009-02-09 18:05:49232machineA$ git bundle create file.bundle master
Junio C Hamanoa3bb6eb2009-02-05 01:26:33233machineA$ git tag -f lastR2bundle master
234----------------
Junio C Hamano601f3e52008-02-25 08:40:42235
Junio C Hamano6bdcc7d2013-01-09 00:15:42236Then 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:
Junio C Hamano601f3e52008-02-25 08:40:42239
Junio C Hamanoa3bb6eb2009-02-05 01:26:33240----------------
Junio C Hamano6bdcc7d2013-01-09 00:15:42241machineB$ git clone -b master /home/me/tmp/file.bundle R2
Junio C Hamanoa3bb6eb2009-02-05 01:26:33242----------------
Junio C Hamano6ac2f142007-03-01 01:24:56243
Junio C Hamanoa3bb6eb2009-02-05 01:26:33244This will define a remote called "origin" in the resulting repository that
Junio C Hamano1de75722009-03-26 08:39:38245lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
Junio C Hamanoa3bb6eb2009-02-05 01:26:33246have an entry like this:
Junio C Hamano6ac2f142007-03-01 01:24:56247
Junio C Hamano601f3e52008-02-25 08:40:42248------------------------
Junio C Hamanoa3bb6eb2009-02-05 01:26:33249[remote "origin"]
Junio C Hamano61169122009-02-09 18:05:49250 url = /home/me/tmp/file.bundle
Junio C Hamano6ac2f142007-03-01 01:24:56251 fetch = refs/heads/*:refs/remotes/origin/*
Junio C Hamano601f3e52008-02-25 08:40:42252------------------------
Junio C Hamano6ac2f142007-03-01 01:24:56253
Junio C Hamano1de75722009-03-26 08:39:38254To 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.
Junio C Hamano6ac2f142007-03-01 01:24:56257
Junio C Hamano1de75722009-03-26 08:39:38258After working some more in the original repository, you can create an
259incremental bundle to update the other repository:
Junio C Hamano6ac2f142007-03-01 01:24:56260
Junio C Hamanoa3bb6eb2009-02-05 01:26:33261----------------
262machineA$ cd R1
Junio C Hamano61169122009-02-09 18:05:49263machineA$ git bundle create file.bundle lastR2bundle..master
Junio C Hamanoa3bb6eb2009-02-05 01:26:33264machineA$ git tag -f lastR2bundle master
265----------------
266
Junio C Hamano1de75722009-03-26 08:39:38267You then transfer the bundle to the other machine to replace
268/home/me/tmp/file.bundle, and pull from it.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33269
270----------------
271machineB$ cd R2
272machineB$ git pull
273----------------
274
275If you know up to what commit the intended recipient repository should
Junio C Hamano1de75722009-03-26 08:39:38276have the necessary objects, you can use that knowledge to specify the
Junio C Hamanod2e30562021-08-24 23:21:51277prerequisites, giving a cut-off point to limit the revisions and objects that go
Junio C Hamano2db3e752010-09-03 21:33:06278in the resulting bundle. The previous example used the lastR2bundle tag
Junio C Hamano1de75722009-03-26 08:39:38279for this purpose, but you can use any other options that you would give to
Junio C Hamanoa3bb6eb2009-02-05 01:26:33280the linkgit:git-log[1] command. Here are more examples:
281
Junio C Hamano1de75722009-03-26 08:39:38282You can use a tag that is present in both:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33283
284----------------
285$ git bundle create mybundle v1.0.0..master
286----------------
287
Junio C Hamanod2e30562021-08-24 23:21:51288You can use a prerequisite based on time:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33289
290----------------
291$ git bundle create mybundle --since=10.days master
292----------------
293
Junio C Hamano1de75722009-03-26 08:39:38294You can use the number of commits:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33295
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
Junio C Hamanod2e30562021-08-24 23:21:51301that was created with a prerequisite:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33302
303----------------
304$ git bundle verify mybundle
305----------------
306
307This will list what commits you must have in order to extract from the
Junio C Hamano1de75722009-03-26 08:39:38308bundle and will error out if you do not have them.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33309
310A bundle from a recipient repository's point of view is just like a
Junio C Hamano1de75722009-03-26 08:39:38311regular repository which it fetches or pulls from. You can, for example, map
312references when fetching:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33313
314----------------
315$ git fetch mybundle master:localRef
316----------------
317
Junio C Hamano2db3e752010-09-03 21:33:06318You can also see what references it offers:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33319
320----------------
321$ git ls-remote mybundle
322----------------
Junio C Hamano6ac2f142007-03-01 01:24:56323
Junio C Hamano04495a12022-08-18 21:13:08324FILE FORMAT
325-----------
326
327See linkgit:gitformat-bundle[5].
328
Junio C Hamano6ac2f142007-03-01 01:24:56329GIT
330---
Junio C Hamanof7c042d2008-06-06 22:50:53331Part of the linkgit:git[1] suite