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