1GIT-BUNDLE(1) Git Manual GIT-BUNDLE(1)
2
3
4
6 git-bundle - Move objects and refs by archive
7
9 git bundle create [-q | --quiet | --progress | --all-progress] [--all-progress-implied]
10 [--version=<version>] <file> <git-rev-list-args>
11 git bundle verify [-q | --quiet] <file>
12 git bundle list-heads <file> [<refname>...]
13 git bundle unbundle [--progress] <file> [<refname>...]
14
16 Create, unpack, and manipulate "bundle" files. Bundles are used for the
17 "offline" transfer of Git objects without an active "server" sitting on
18 the other side of the network connection.
19
20 They can be used to create both incremental and full backups of a
21 repository, and to relay the state of the references in one repository
22 to another.
23
24 Git commands that fetch or otherwise "read" via protocols such as
25 ssh:// and https:// can also operate on bundle files. It is possible
26 git-clone(1) a new repository from a bundle, to use git-fetch(1) to
27 fetch from one, and to list the references contained within it with
28 git-ls-remote(1). There’s no corresponding "write" support, i.e.a git
29 push into a bundle is not supported.
30
31 See the "EXAMPLES" section below for examples of how to use bundles.
32
34 Bundles are .pack files (see git-pack-objects(1)) with a header
35 indicating what references are contained within the bundle.
36
37 Like the the packed archive format itself bundles can either be
38 self-contained, or be created using exclusions. See the "OBJECT
39 PREREQUISITES" section below.
40
41 Bundles created using revision exclusions are "thin packs" created
42 using the --thin option to git-pack-objects(1), and unbundled using the
43 --fix-thin option to git-index-pack(1).
44
45 There is no option to create a "thick pack" when using revision
46 exclusions, and users should not be concerned about the difference. By
47 using "thin packs", bundles created using exclusions are smaller in
48 size. That they’re "thin" under the hood is merely noted here as a
49 curiosity, and as a reference to other documentation.
50
51 See the bundle-format documentation[1] for more details and the
52 discussion of "thin pack" in the pack format documentation[2] for
53 further details.
54
56 create [options] <file> <git-rev-list-args>
57 Used to create a bundle named file. This requires the
58 <git-rev-list-args> arguments to define the bundle contents.
59 options contains the options specific to the git bundle create
60 subcommand.
61
62 verify <file>
63 Used to check that a bundle file is valid and will apply cleanly to
64 the current repository. This includes checks on the bundle format
65 itself as well as checking that the prerequisite commits exist and
66 are fully linked in the current repository. Then, git bundle prints
67 a list of missing commits, if any. Finally, information about
68 additional capabilities, such as "object filter", is printed. See
69 "Capabilities" in link:technical/bundle-format.html for more
70 information. The exit code is zero for success, but will be nonzero
71 if the bundle file is invalid.
72
73 list-heads <file>
74 Lists the references defined in the bundle. If followed by a list
75 of references, only references matching those given are printed
76 out.
77
78 unbundle <file>
79 Passes the objects in the bundle to git index-pack for storage in
80 the repository, then prints the names of all defined references. If
81 a list of references is given, only references matching those in
82 the list are printed. This command is really plumbing, intended to
83 be called only by git fetch.
84
85 <git-rev-list-args>
86 A list of arguments, acceptable to git rev-parse and git rev-list
87 (and containing a named ref, see SPECIFYING REFERENCES below), that
88 specifies the specific objects and references to transport. For
89 example, master~10..master causes the current master reference to
90 be packaged along with all objects added since its 10th ancestor
91 commit. There is no explicit limit to the number of references and
92 objects that may be packaged.
93
94 [<refname>...]
95 A list of references used to limit the references reported as
96 available. This is principally of use to git fetch, which expects
97 to receive only those references asked for and not necessarily
98 everything in the pack (in this case, git bundle acts like git
99 fetch-pack).
100
101 --progress
102 Progress status is reported on the standard error stream by default
103 when it is attached to a terminal, unless -q is specified. This
104 flag forces progress status even if the standard error stream is
105 not directed to a terminal.
106
107 --all-progress
108 When --stdout is specified then progress report is displayed during
109 the object count and compression phases but inhibited during the
110 write-out phase. The reason is that in some cases the output stream
111 is directly linked to another command which may wish to display
112 progress status of its own as it processes incoming pack data. This
113 flag is like --progress except that it forces progress report for
114 the write-out phase as well even if --stdout is used.
115
116 --all-progress-implied
117 This is used to imply --all-progress whenever progress display is
118 activated. Unlike --all-progress this flag doesn’t actually force
119 any progress display by itself.
120
121 --version=<version>
122 Specify the bundle version. Version 2 is the older format and can
123 only be used with SHA-1 repositories; the newer version 3 contains
124 capabilities that permit extensions. The default is the oldest
125 supported format, based on the hash algorithm in use.
126
127 -q, --quiet
128 This flag makes the command not to report its progress on the
129 standard error stream.
130
132 Revisions must be accompanied by reference names to be packaged in a
133 bundle.
134
135 More than one reference may be packaged, and more than one set of
136 prerequisite objects can be specified. The objects packaged are those
137 not contained in the union of the prerequisites.
138
139 The git bundle create command resolves the reference names for you
140 using the same rules as git rev-parse --abbrev-ref=loose. Each
141 prerequisite can be specified explicitly (e.g. ^master~10), or
142 implicitly (e.g. master~10..master, --since=10.days.ago master).
143
144 All of these simple cases are OK (assuming we have a "master" and
145 "next" branch):
146
147 $ git bundle create master.bundle master
148 $ echo master | git bundle create master.bundle --stdin
149 $ git bundle create master-and-next.bundle master next
150 $ (echo master; echo next) | git bundle create master-and-next.bundle --stdin
151
152 And so are these (and the same but omitted --stdin examples):
153
154 $ git bundle create recent-master.bundle master~10..master
155 $ git bundle create recent-updates.bundle master~10..master next~5..next
156
157 A revision name or a range whose right-hand-side cannot be resolved to
158 a reference is not accepted:
159
160 $ git bundle create HEAD.bundle $(git rev-parse HEAD)
161 fatal: Refusing to create empty bundle.
162 $ git bundle create master-yesterday.bundle master~10..master~5
163 fatal: Refusing to create empty bundle.
164
166 When creating bundles it is possible to create a self-contained bundle
167 that can be unbundled in a repository with no common history, as well
168 as providing negative revisions to exclude objects needed in the
169 earlier parts of the history.
170
171 Feeding a revision such as new to git bundle create will create a
172 bundle file that contains all the objects reachable from the revision
173 new. That bundle can be unbundled in any repository to obtain a full
174 history that leads to the revision new:
175
176 $ git bundle create full.bundle new
177
178 A revision range such as old..new will produce a bundle file that will
179 require the revision old (and any objects reachable from it) to exist
180 for the bundle to be "unbundle"-able:
181
182 $ git bundle create full.bundle old..new
183
184 A self-contained bundle without any prerequisites can be extracted into
185 anywhere, even into an empty repository, or be cloned from (i.e., new,
186 but not old..new).
187
188 It is okay to err on the side of caution, causing the bundle file to
189 contain objects already in the destination, as these are ignored when
190 unpacking at the destination.
191
192 If you want to match git clone --mirror, which would include your refs
193 such as refs/remotes/*, use --all. If you want to provide the same set
194 of refs that a clone directly from the source repository would get, use
195 --branches --tags for the <git-rev-list-args>.
196
197 The git bundle verify command can be used to check whether your
198 recipient repository has the required prerequisite commits for a
199 bundle.
200
202 Assume you want to transfer the history from a repository R1 on machine
203 A to another repository R2 on machine B. For whatever reason, direct
204 connection between A and B is not allowed, but we can move data from A
205 to B via some mechanism (CD, email, etc.). We want to update R2 with
206 development made on the branch master in R1.
207
208 To bootstrap the process, you can first create a bundle that does not
209 have any prerequisites. You can use a tag to remember up to what commit
210 you last processed, in order to make it easy to later update the other
211 repository with an incremental bundle:
212
213 machineA$ cd R1
214 machineA$ git bundle create file.bundle master
215 machineA$ git tag -f lastR2bundle master
216
217 Then you transfer file.bundle to the target machine B. Because this
218 bundle does not require any existing object to be extracted, you can
219 create a new repository on machine B by cloning from it:
220
221 machineB$ git clone -b master /home/me/tmp/file.bundle R2
222
223 This will define a remote called "origin" in the resulting repository
224 that lets you fetch and pull from the bundle. The $GIT_DIR/config file
225 in R2 will have an entry like this:
226
227 [remote "origin"]
228 url = /home/me/tmp/file.bundle
229 fetch = refs/heads/*:refs/remotes/origin/*
230
231 To update the resulting mine.git repository, you can fetch or pull
232 after replacing the bundle stored at /home/me/tmp/file.bundle with
233 incremental updates.
234
235 After working some more in the original repository, you can create an
236 incremental bundle to update the other repository:
237
238 machineA$ cd R1
239 machineA$ git bundle create file.bundle lastR2bundle..master
240 machineA$ git tag -f lastR2bundle master
241
242 You then transfer the bundle to the other machine to replace
243 /home/me/tmp/file.bundle, and pull from it.
244
245 machineB$ cd R2
246 machineB$ git pull
247
248 If you know up to what commit the intended recipient repository should
249 have the necessary objects, you can use that knowledge to specify the
250 prerequisites, giving a cut-off point to limit the revisions and
251 objects that go in the resulting bundle. The previous example used the
252 lastR2bundle tag for this purpose, but you can use any other options
253 that you would give to the git-log(1) command. Here are more examples:
254
255 You can use a tag that is present in both:
256
257 $ git bundle create mybundle v1.0.0..master
258
259 You can use a prerequisite based on time:
260
261 $ git bundle create mybundle --since=10.days master
262
263 You can use the number of commits:
264
265 $ git bundle create mybundle -10 master
266
267 You can run git-bundle verify to see if you can extract from a bundle
268 that was created with a prerequisite:
269
270 $ git bundle verify mybundle
271
272 This will list what commits you must have in order to extract from the
273 bundle and will error out if you do not have them.
274
275 A bundle from a recipient repository’s point of view is just like a
276 regular repository which it fetches or pulls from. You can, for
277 example, map references when fetching:
278
279 $ git fetch mybundle master:localRef
280
281 You can also see what references it offers:
282
283 $ git ls-remote mybundle
284
286 Part of the git(1) suite
287
289 1. the bundle-format documentation
290 file:///usr/share/doc/git/technical/bundle-format.html
291
292 2. the pack format documentation
293 file:///usr/share/doc/git/technical/pack-format.html
294
295
296
297Git 2.36.1 2022-05-05 GIT-BUNDLE(1)