Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/Documentation/git-bundle.adoc # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / Documentation / git-bundle.adoc` 375 lines ยท 13413 bytes Raw Blame History 1 git-bundle(1) 2 ============= 3 4 NAME 5 ---- 6 git-bundle - Move objects and refs by archive 7 8 9 SYNOPSIS 10 -------- 11 [verse] 12 'git bundle' create [-q | --quiet | --progress] 13 [--version=] 14 'git bundle' verify [-q | --quiet] 15 'git bundle' list-heads [...] 16 'git bundle' unbundle [--progress] [...] 17 18 DESCRIPTION 19 ----------- 20 21 Create, unpack, and manipulate "bundle" files. Bundles are used for 22 the "offline" transfer of Git objects without an active "server" 23 sitting on the other side of the network connection. 24 25 They can be used to create both incremental and full backups of a 26 repository (see the "full backup" example in "EXAMPLES"), and to relay 27 the state of the references in one repository to another (see the second 28 example). 29 30 Git commands that fetch or otherwise "read" via protocols such as 31 `ssh://` and `https://` can also operate on bundle files. It is 32 possible linkgit:git-clone[1] a new repository from a bundle, to use 33 linkgit:git-fetch[1] to fetch from one, and to list the references 34 contained within it with linkgit:git-ls-remote[1]. There's no 35 corresponding "write" support, i.e. a 'git push' into a bundle is not 36 supported. 37 38 BUNDLE FORMAT 39 ------------- 40 41 Bundles are `.pack` files (see linkgit:git-pack-objects[1]) with a 42 header indicating what references are contained within the bundle. 43 44 Like the packed archive format itself bundles can either be 45 self-contained, or be created using exclusions. 46 See the <> section below. 47 48 Bundles created using revision exclusions are "thin packs" created 49 using the `--thin` option to linkgit:git-pack-objects[1], and 50 unbundled using the `--fix-thin` option to linkgit:git-index-pack[1]. 51 52 There is no option to create a "thick pack" when using revision 53 exclusions, and users should not be concerned about the difference. By 54 using "thin packs", bundles created using exclusions are smaller in 55 size. That they're "thin" under the hood is merely noted here as a 56 curiosity, and as a reference to other documentation. 57 58 See linkgit:gitformat-bundle[5] for more details and the discussion of 59 "thin pack" in linkgit:gitformat-pack[5] for further details. 60 61 OPTIONS 62 ------- 63 64 create [options] :: 65 Used to create a bundle named 'file'. This requires the 66 '' arguments to define the bundle contents. 67 'options' contains the options specific to the 'git bundle create' 68 subcommand. If 'file' is `-`, the bundle is written to stdout. 69 70 verify :: 71 Used to check that a bundle file is valid and will apply 72 cleanly to the current repository. This includes checks on the 73 bundle format itself as well as checking that the prerequisite 74 commits exist and are fully linked in the current repository. 75 Then, 'git bundle' prints a list of missing commits, if any. 76 Finally, information about additional capabilities, such as "object 77 filter", is printed. See "Capabilities" in linkgit:gitformat-bundle[5] 78 for more information. The exit code is zero for success, but will 79 be nonzero if the bundle file is invalid. If 'file' is `-`, the 80 bundle is read from stdin. 81 82 list-heads :: 83 Lists the references defined in the bundle. If followed by a 84 list of references, only references matching those given are 85 printed out. If 'file' is `-`, the bundle is read from stdin. 86 87 unbundle :: 88 Passes the objects in the bundle to 'git index-pack' 89 for storage in the repository, then prints the names of all 90 defined references. If a list of references is given, only 91 references matching those in the list are printed. This command is 92 really plumbing, intended to be called only by 'git fetch'. 93 If 'file' is `-`, the bundle is read from stdin. 94 95 :: 96 A list of arguments, acceptable to 'git rev-parse' and 97 'git rev-list' (and containing a named ref, see 98 <> 99 below), that specifies the specific objects and references 100 to transport. For example, `master~10..master` causes the 101 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. 105 106 107 [...]:: 108 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'). 113 114 --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 120 --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 126 -q:: 127 --quiet:: 128 This flag makes the command not to report its progress 129 on the standard error stream. 130 131 [[SPECIFYING_REFERENCES]] 132 SPECIFYING REFERENCES 133 --------------------- 134 135 Revisions must be accompanied by reference names to be packaged in a 136 bundle. Alternatively `--all` can be used to package all refs. 137 138 More than one reference may be packaged, and more than one set of prerequisite objects can 139 be specified. The objects packaged are those not contained in the 140 union of the prerequisites. 141 142 The 'git bundle create' command resolves the reference names for you 143 using the same rules as `git rev-parse --abbrev-ref=loose`. Each 144 prerequisite can be specified explicitly (e.g. `^master~10`), or implicitly 145 (e.g. `master~10..master`, `--since=10.days.ago master`). 146 147 All of these simple cases are OK (assuming we have a "master" and 148 "next" branch): 149 150 ---------------- 151 $ git bundle create master.bundle master 152 $ echo master | git bundle create master.bundle --stdin 153 $ git bundle create master-and-next.bundle master next 154 $ (echo master; echo next) | git bundle create master-and-next.bundle --stdin 155 ---------------- 156 157 And so are these (and the same but omitted `--stdin` examples): 158 159 ---------------- 160 $ git bundle create recent-master.bundle master~10..master 161 $ git bundle create recent-updates.bundle master~10..master next~5..next 162 ---------------- 163 164 A revision name or a range whose right-hand-side cannot be resolved to 165 a reference is not accepted: 166 167 ---------------- 168 $ git bundle create HEAD.bundle $(git rev-parse HEAD) 169 fatal: Refusing to create empty bundle. 170 $ git bundle create master-yesterday.bundle master~10..master~5 171 fatal: Refusing to create empty bundle. 172 ---------------- 173 174 [[OBJECT_PREREQUISITES]] 175 OBJECT PREREQUISITES 176 -------------------- 177 178 When creating bundles it is possible to create a self-contained bundle 179 that can be unbundled in a repository with no common history, as well 180 as providing negative revisions to exclude objects needed in the 181 earlier parts of the history. 182 183 Feeding a revision such as `new` to `git bundle create` will create a 184 bundle file that contains all the objects reachable from the revision 185 `new`. That bundle can be unbundled in any repository to obtain a full 186 history that leads to the revision `new`: 187 188 ---------------- 189 $ git bundle create full.bundle new 190 ---------------- 191 192 A revision range such as `old..new` will produce a bundle file that 193 will require the revision `old` (and any objects reachable from it) 194 to exist for the bundle to be "unbundle"-able: 195 196 ---------------- 197 $ git bundle create full.bundle old..new 198 ---------------- 199 200 A self-contained bundle without any prerequisites can be extracted 201 into anywhere, even into an empty repository, or be cloned from 202 (i.e., `new`, but not `old..new`). 203 204 It is okay to err on the side of caution, causing the bundle file 205 to contain objects already in the destination, as these are ignored 206 when unpacking at the destination. 207 208 If you want to provide the same set of refs that a clone directly 209 from the source repository would get, use `--branches --tags` for 210 the ``. 211 212 The 'git bundle verify' command can be used to check whether your 213 recipient repository has the required prerequisite commits for a 214 bundle. 215 216 EXAMPLES 217 -------- 218 219 We'll discuss two cases: 220 221 1. Taking a full backup of a repository 222 2. Transferring the history of a repository to another machine when the 223 two machines have no direct connection 224 225 First let's consider a full backup of the repository. The following 226 command will take a full backup of the repository in the sense that all 227 refs are included in the bundle: 228 229 ---------------- 230 $ git bundle create backup.bundle --all 231 ---------------- 232 233 But note again that this is only for the refs, i.e. you will only 234 include refs and commits reachable from those refs. You will not 235 include other local state, such as the contents of the index, working 236 tree, the stash, per-repository configuration, hooks, etc. 237 238 You can later recover that repository by using for example 239 linkgit:git-clone[1]: 240 241 ---------------- 242 $ git clone backup.bundle 243 ---------------- 244 245 For the next example, assume you want to transfer the history from a 246 repository R1 on machine A to another repository R2 on machine B. 247 For whatever reason, direct connection between A and B is not allowed, 248 but we can move data from A to B via some mechanism (CD, email, etc.). 249 We want to update R2 with development made on the branch master in R1. 250 251 To bootstrap the process, you can first create a bundle that does not have 252 any prerequisites. You can use a tag to remember up to what commit you last 253 processed, in order to make it easy to later update the other repository 254 with an incremental bundle: 255 256 ---------------- 257 machineA$ cd R1 258 machineA$ git bundle create file.bundle master 259 machineA$ git tag -f lastR2bundle master 260 ---------------- 261 262 Then you transfer file.bundle to the target machine B. Because this 263 bundle does not require any existing object to be extracted, you can 264 create a new repository on machine B by cloning from it: 265 266 ---------------- 267 machineB$ git clone -b master /home/me/tmp/file.bundle R2 268 ---------------- 269 270 This will define a remote called "origin" in the resulting repository that 271 lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will 272 have an entry like this: 273 274 ------------------------ 275 [remote "origin"] 276 url = /home/me/tmp/file.bundle 277 fetch = refs/heads/*:refs/remotes/origin/* 278 ------------------------ 279 280 To update the resulting mine.git repository, you can fetch or pull after 281 replacing the bundle stored at /home/me/tmp/file.bundle with incremental 282 updates. 283 284 After working some more in the original repository, you can create an 285 incremental bundle to update the other repository: 286 287 ---------------- 288 machineA$ cd R1 289 machineA$ git bundle create file.bundle lastR2bundle..master 290 machineA$ git tag -f lastR2bundle master 291 ---------------- 292 293 You then transfer the bundle to the other machine to replace 294 /home/me/tmp/file.bundle, and pull from it. 295 296 ---------------- 297 machineB$ cd R2 298 machineB$ git pull 299 ---------------- 300 301 If you know up to what commit the intended recipient repository should 302 have the necessary objects, you can use that knowledge to specify the 303 prerequisites, giving a cut-off point to limit the revisions and objects that go 304 in the resulting bundle. The previous example used the lastR2bundle tag 305 for this purpose, but you can use any other options that you would give to 306 the linkgit:git-log[1] command. Here are more examples: 307 308 You can use a tag that is present in both: 309 310 ---------------- 311 $ git bundle create mybundle v1.0.0..master 312 ---------------- 313 314 You can use a prerequisite based on time: 315 316 ---------------- 317 $ git bundle create mybundle --since=10.days master 318 ---------------- 319 320 You can use the number of commits: 321 322 ---------------- 323 $ git bundle create mybundle -10 master 324 ---------------- 325 326 You can run `git-bundle verify` to see if you can extract from a bundle 327 that was created with a prerequisite: 328 329 ---------------- 330 $ git bundle verify mybundle 331 ---------------- 332 333 This will list what commits you must have in order to extract from the 334 bundle and will error out if you do not have them. 335 336 A bundle from a recipient repository's point of view is just like a 337 regular repository which it fetches or pulls from. You can, for example, map 338 references when fetching: 339 340 ---------------- 341 $ git fetch mybundle master:localRef 342 ---------------- 343 344 You can also see what references it offers: 345 346 ---------------- 347 $ git ls-remote mybundle 348 ---------------- 349 350 DISCUSSION 351 ---------- 352 353 A naive way to make a full backup of a repository is to use something to 354 the effect of `cp -r `. This is discouraged since 355 the repository could be written to during the copy operation. In turn 356 some files at `` could be corrupted. 357 358 This is why it is recommended to use Git tooling for making repository 359 backups, either with this command or with e.g. linkgit:git-clone[1]. 360 But keep in mind that these tools will not help you backup state other 361 than refs and commits. In other words they will not help you backup 362 contents of the index, working tree, the stash, per-repository 363 configuration, hooks, etc. 364 365 See also linkgit:gitfaq[7], section "TRANSFERS" for a discussion of the 366 problems associated with file syncing across systems. 367 368 FILE FORMAT 369 ----------- 370 371 See linkgit:gitformat-bundle[5]. 372 373 GIT 374 --- 375 Part of the linkgit:git[1] suite