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]
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 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 gitformat-bundle(5) for more details and the discussion of "thin
52 pack" in gitformat-pack(5) for further details.
53
55 create [options] <file> <git-rev-list-args>
56 Used to create a bundle named file. This requires the
57 <git-rev-list-args> arguments to define the bundle contents.
58 options contains the options specific to the git bundle create
59 subcommand. If file is -, the bundle is written to stdout.
60
61 verify <file>
62 Used to check that a bundle file is valid and will apply cleanly to
63 the current repository. This includes checks on the bundle format
64 itself as well as checking that the prerequisite commits exist and
65 are fully linked in the current repository. Then, git bundle prints
66 a list of missing commits, if any. Finally, information about
67 additional capabilities, such as "object filter", is printed. See
68 "Capabilities" in gitformat-bundle(5) for more information. The
69 exit code is zero for success, but will be nonzero if the bundle
70 file is invalid. If file is -, the bundle is read from stdin.
71
72 list-heads <file>
73 Lists the references defined in the bundle. If followed by a list
74 of references, only references matching those given are printed
75 out. If file is -, the bundle is read from stdin.
76
77 unbundle <file>
78 Passes the objects in the bundle to git index-pack for storage in
79 the repository, then prints the names of all defined references. If
80 a list of references is given, only references matching those in
81 the list are printed. This command is really plumbing, intended to
82 be called only by git fetch. If file is -, the bundle is read from
83 stdin.
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 --version=<version>
108 Specify the bundle version. Version 2 is the older format and can
109 only be used with SHA-1 repositories; the newer version 3 contains
110 capabilities that permit extensions. The default is the oldest
111 supported format, based on the hash algorithm in use.
112
113 -q, --quiet
114 This flag makes the command not to report its progress on the
115 standard error stream.
116
118 Revisions must be accompanied by reference names to be packaged in a
119 bundle.
120
121 More than one reference may be packaged, and more than one set of
122 prerequisite objects can be specified. The objects packaged are those
123 not contained in the union of the prerequisites.
124
125 The git bundle create command resolves the reference names for you
126 using the same rules as git rev-parse --abbrev-ref=loose. Each
127 prerequisite can be specified explicitly (e.g. ^master~10), or
128 implicitly (e.g. master~10..master, --since=10.days.ago master).
129
130 All of these simple cases are OK (assuming we have a "master" and
131 "next" branch):
132
133 $ git bundle create master.bundle master
134 $ echo master | git bundle create master.bundle --stdin
135 $ git bundle create master-and-next.bundle master next
136 $ (echo master; echo next) | git bundle create master-and-next.bundle --stdin
137
138 And so are these (and the same but omitted --stdin examples):
139
140 $ git bundle create recent-master.bundle master~10..master
141 $ git bundle create recent-updates.bundle master~10..master next~5..next
142
143 A revision name or a range whose right-hand-side cannot be resolved to
144 a reference is not accepted:
145
146 $ git bundle create HEAD.bundle $(git rev-parse HEAD)
147 fatal: Refusing to create empty bundle.
148 $ git bundle create master-yesterday.bundle master~10..master~5
149 fatal: Refusing to create empty bundle.
150
152 When creating bundles it is possible to create a self-contained bundle
153 that can be unbundled in a repository with no common history, as well
154 as providing negative revisions to exclude objects needed in the
155 earlier parts of the history.
156
157 Feeding a revision such as new to git bundle create will create a
158 bundle file that contains all the objects reachable from the revision
159 new. That bundle can be unbundled in any repository to obtain a full
160 history that leads to the revision new:
161
162 $ git bundle create full.bundle new
163
164 A revision range such as old..new will produce a bundle file that will
165 require the revision old (and any objects reachable from it) to exist
166 for the bundle to be "unbundle"-able:
167
168 $ git bundle create full.bundle old..new
169
170 A self-contained bundle without any prerequisites can be extracted into
171 anywhere, even into an empty repository, or be cloned from (i.e., new,
172 but not old..new).
173
174 It is okay to err on the side of caution, causing the bundle file to
175 contain objects already in the destination, as these are ignored when
176 unpacking at the destination.
177
178 If you want to match git clone --mirror, which would include your refs
179 such as refs/remotes/*, use --all. If you want to provide the same set
180 of refs that a clone directly from the source repository would get, use
181 --branches --tags for the <git-rev-list-args>.
182
183 The git bundle verify command can be used to check whether your
184 recipient repository has the required prerequisite commits for a
185 bundle.
186
188 Assume you want to transfer the history from a repository R1 on machine
189 A to another repository R2 on machine B. For whatever reason, direct
190 connection between A and B is not allowed, but we can move data from A
191 to B via some mechanism (CD, email, etc.). We want to update R2 with
192 development made on the branch master in R1.
193
194 To bootstrap the process, you can first create a bundle that does not
195 have any prerequisites. You can use a tag to remember up to what commit
196 you last processed, in order to make it easy to later update the other
197 repository with an incremental bundle:
198
199 machineA$ cd R1
200 machineA$ git bundle create file.bundle master
201 machineA$ git tag -f lastR2bundle master
202
203 Then you transfer file.bundle to the target machine B. Because this
204 bundle does not require any existing object to be extracted, you can
205 create a new repository on machine B by cloning from it:
206
207 machineB$ git clone -b master /home/me/tmp/file.bundle R2
208
209 This will define a remote called "origin" in the resulting repository
210 that lets you fetch and pull from the bundle. The $GIT_DIR/config file
211 in R2 will have an entry like this:
212
213 [remote "origin"]
214 url = /home/me/tmp/file.bundle
215 fetch = refs/heads/*:refs/remotes/origin/*
216
217 To update the resulting mine.git repository, you can fetch or pull
218 after replacing the bundle stored at /home/me/tmp/file.bundle with
219 incremental updates.
220
221 After working some more in the original repository, you can create an
222 incremental bundle to update the other repository:
223
224 machineA$ cd R1
225 machineA$ git bundle create file.bundle lastR2bundle..master
226 machineA$ git tag -f lastR2bundle master
227
228 You then transfer the bundle to the other machine to replace
229 /home/me/tmp/file.bundle, and pull from it.
230
231 machineB$ cd R2
232 machineB$ git pull
233
234 If you know up to what commit the intended recipient repository should
235 have the necessary objects, you can use that knowledge to specify the
236 prerequisites, giving a cut-off point to limit the revisions and
237 objects that go in the resulting bundle. The previous example used the
238 lastR2bundle tag for this purpose, but you can use any other options
239 that you would give to the git-log(1) command. Here are more examples:
240
241 You can use a tag that is present in both:
242
243 $ git bundle create mybundle v1.0.0..master
244
245 You can use a prerequisite based on time:
246
247 $ git bundle create mybundle --since=10.days master
248
249 You can use the number of commits:
250
251 $ git bundle create mybundle -10 master
252
253 You can run git-bundle verify to see if you can extract from a bundle
254 that was created with a prerequisite:
255
256 $ git bundle verify mybundle
257
258 This will list what commits you must have in order to extract from the
259 bundle and will error out if you do not have them.
260
261 A bundle from a recipient repository’s point of view is just like a
262 regular repository which it fetches or pulls from. You can, for
263 example, map references when fetching:
264
265 $ git fetch mybundle master:localRef
266
267 You can also see what references it offers:
268
269 $ git ls-remote mybundle
270
272 See gitformat-bundle(5).
273
275 Part of the git(1) suite
276
277
278
279Git 2.43.0 11/20/2023 GIT-BUNDLE(1)