blob: c3a066e60cb40d893287f813a4a007c4db42b1bb [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 Hamanofce7c7e2008-07-02 03:06:3812'git bundle' create <file> <git-rev-list args>
13'git bundle' verify <file>
14'git bundle' list-heads <file> [refname...]
15'git bundle' unbundle <file> [refname...]
Junio C Hamano6ac2f142007-03-01 01:24:5616
17DESCRIPTION
18-----------
19
20Some workflows require that one or more branches of development on one
21machine be replicated on another machine, but the two machines cannot
Junio C Hamano1de75722009-03-26 08:39:3822be directly connected, and therefore the interactive git protocols (git,
23ssh, rsync, http) cannot be used. This command provides support for
Junio C Hamanoba4b9282008-07-06 05:20:3124'git-fetch' and 'git-pull' to operate by packaging objects and references
Junio C Hamano6ac2f142007-03-01 01:24:5625in an archive at the originating machine, then importing those into
Junio C Hamanoba4b9282008-07-06 05:20:3126another repository using 'git-fetch' and 'git-pull'
Junio C Hamano2bd8a742009-12-01 21:16:5927after moving the archive by some means (e.g., by sneakernet). As no
Junio C Hamano1de75722009-03-26 08:39:3828direct connection between the repositories exists, the user must specify a
Junio C Hamano6ac2f142007-03-01 01:24:5629basis for the bundle that is held by the destination repository: the
30bundle assumes that all objects in the basis are already in the
31destination repository.
32
33OPTIONS
34-------
35
36create <file>::
37 Used to create a bundle named 'file'. This requires the
Junio C Hamanoba4b9282008-07-06 05:20:3138 'git-rev-list' arguments to define the bundle contents.
Junio C Hamano6ac2f142007-03-01 01:24:5639
40verify <file>::
41 Used to check that a bundle file is valid and will apply
42 cleanly to the current repository. This includes checks on the
43 bundle format itself as well as checking that the prerequisite
44 commits exist and are fully linked in the current repository.
Junio C Hamanoba4b9282008-07-06 05:20:3145 'git-bundle' prints a list of missing commits, if any, and exits
Junio C Hamano1de75722009-03-26 08:39:3846 with a non-zero status.
Junio C Hamano6ac2f142007-03-01 01:24:5647
48list-heads <file>::
49 Lists the references defined in the bundle. If followed by a
50 list of references, only references matching those given are
51 printed out.
52
53unbundle <file>::
Junio C Hamanoba4b9282008-07-06 05:20:3154 Passes the objects in the bundle to 'git-index-pack'
Junio C Hamano6ac2f142007-03-01 01:24:5655 for storage in the repository, then prints the names of all
Junio C Hamano1de75722009-03-26 08:39:3856 defined references. If a list of references is given, only
57 references matching those in the list are printed. This command is
Junio C Hamanoba4b9282008-07-06 05:20:3158 really plumbing, intended to be called only by 'git-fetch'.
Junio C Hamano6ac2f142007-03-01 01:24:5659
60[git-rev-list-args...]::
Junio C Hamanoba4b9282008-07-06 05:20:3161 A list of arguments, acceptable to 'git-rev-parse' and
Junio C Hamano1de75722009-03-26 08:39:3862 'git-rev-list', that specifies the specific objects and references
63 to transport. For example, `master\~10..master` causes the
Junio C Hamano6ac2f142007-03-01 01:24:5664 current master reference to be packaged along with all objects
65 added since its 10th ancestor commit. There is no explicit
66 limit to the number of references and objects that may be
67 packaged.
68
69
70[refname...]::
71 A list of references used to limit the references reported as
Junio C Hamanoba4b9282008-07-06 05:20:3172 available. This is principally of use to 'git-fetch', which
Junio C Hamanoa3fd83c2007-03-02 10:34:3673 expects to receive only those references asked for and not
Junio C Hamano1de75722009-03-26 08:39:3874 necessarily everything in the pack (in this case, 'git-bundle' acts
75 like 'git-fetch-pack').
Junio C Hamano6ac2f142007-03-01 01:24:5676
77SPECIFYING REFERENCES
78---------------------
79
Junio C Hamanoba4b9282008-07-06 05:20:3180'git-bundle' will only package references that are shown by
81'git-show-ref': this includes heads, tags, and remote heads. References
Junio C Hamano1de75722009-03-26 08:39:3882such as `master\~1` cannot be packaged, but are perfectly suitable for
Junio C Hamano6ac2f142007-03-01 01:24:5683defining the basis. More than one reference may be packaged, and more
84than one basis can be specified. The objects packaged are those not
85contained in the union of the given bases. Each basis can be
Junio C Hamano1de75722009-03-26 08:39:3886specified explicitly (e.g. `^master\~10`), or implicitly (e.g.
87`master\~10..master`, `--since=10.days.ago master`).
Junio C Hamano6ac2f142007-03-01 01:24:5688
89It is very important that the basis used be held by the destination.
Junio C Hamano1de75722009-03-26 08:39:3890It is okay to err on the side of caution, causing the bundle file
91to contain objects already in the destination, as these are ignored
Junio C Hamano6ac2f142007-03-01 01:24:5692when unpacking at the destination.
93
94EXAMPLE
95-------
96
Junio C Hamanoa3bb6eb2009-02-05 01:26:3397Assume you want to transfer the history from a repository R1 on machine A
98to another repository R2 on machine B.
Junio C Hamano6ac2f142007-03-01 01:24:5699For whatever reason, direct connection between A and B is not allowed,
Junio C Hamano1de75722009-03-26 08:39:38100but we can move data from A to B via some mechanism (CD, email, etc.).
101We want to update R2 with development made on the branch master in R1.
Junio C Hamano601f3e52008-02-25 08:40:42102
Junio C Hamano1de75722009-03-26 08:39:38103To bootstrap the process, you can first create a bundle that does not have
104any basis. You can use a tag to remember up to what commit you last
105processed, in order to make it easy to later update the other repository
106with an incremental bundle:
Junio C Hamano601f3e52008-02-25 08:40:42107
Junio C Hamanoa3bb6eb2009-02-05 01:26:33108----------------
109machineA$ cd R1
Junio C Hamano61169122009-02-09 18:05:49110machineA$ git bundle create file.bundle master
Junio C Hamanoa3bb6eb2009-02-05 01:26:33111machineA$ git tag -f lastR2bundle master
112----------------
Junio C Hamano601f3e52008-02-25 08:40:42113
Junio C Hamano1de75722009-03-26 08:39:38114Then you transfer file.bundle to the target machine B. If you are creating
115the repository on machine B, then you can clone from the bundle as if it
116were a remote repository instead of creating an empty repository and then
117pulling or fetching objects from the bundle:
Junio C Hamano601f3e52008-02-25 08:40:42118
Junio C Hamanoa3bb6eb2009-02-05 01:26:33119----------------
Junio C Hamano61169122009-02-09 18:05:49120machineB$ git clone /home/me/tmp/file.bundle R2
Junio C Hamanoa3bb6eb2009-02-05 01:26:33121----------------
Junio C Hamano6ac2f142007-03-01 01:24:56122
Junio C Hamanoa3bb6eb2009-02-05 01:26:33123This will define a remote called "origin" in the resulting repository that
Junio C Hamano1de75722009-03-26 08:39:38124lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
Junio C Hamanoa3bb6eb2009-02-05 01:26:33125have an entry like this:
Junio C Hamano6ac2f142007-03-01 01:24:56126
Junio C Hamano601f3e52008-02-25 08:40:42127------------------------
Junio C Hamanoa3bb6eb2009-02-05 01:26:33128[remote "origin"]
Junio C Hamano61169122009-02-09 18:05:49129 url = /home/me/tmp/file.bundle
Junio C Hamano6ac2f142007-03-01 01:24:56130 fetch = refs/heads/*:refs/remotes/origin/*
Junio C Hamano601f3e52008-02-25 08:40:42131------------------------
Junio C Hamano6ac2f142007-03-01 01:24:56132
Junio C Hamano1de75722009-03-26 08:39:38133To update the resulting mine.git repository, you can fetch or pull after
134replacing the bundle stored at /home/me/tmp/file.bundle with incremental
135updates.
Junio C Hamano6ac2f142007-03-01 01:24:56136
Junio C Hamano1de75722009-03-26 08:39:38137After working some more in the original repository, you can create an
138incremental bundle to update the other repository:
Junio C Hamano6ac2f142007-03-01 01:24:56139
Junio C Hamanoa3bb6eb2009-02-05 01:26:33140----------------
141machineA$ cd R1
Junio C Hamano61169122009-02-09 18:05:49142machineA$ git bundle create file.bundle lastR2bundle..master
Junio C Hamanoa3bb6eb2009-02-05 01:26:33143machineA$ git tag -f lastR2bundle master
144----------------
145
Junio C Hamano1de75722009-03-26 08:39:38146You then transfer the bundle to the other machine to replace
147/home/me/tmp/file.bundle, and pull from it.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33148
149----------------
150machineB$ cd R2
151machineB$ git pull
152----------------
153
154If you know up to what commit the intended recipient repository should
Junio C Hamano1de75722009-03-26 08:39:38155have the necessary objects, you can use that knowledge to specify the
Junio C Hamanoa3bb6eb2009-02-05 01:26:33156basis, giving a cut-off point to limit the revisions and objects that go
157in the resulting bundle. The previous example used lastR2bundle tag
Junio C Hamano1de75722009-03-26 08:39:38158for this purpose, but you can use any other options that you would give to
Junio C Hamanoa3bb6eb2009-02-05 01:26:33159the linkgit:git-log[1] command. Here are more examples:
160
Junio C Hamano1de75722009-03-26 08:39:38161You can use a tag that is present in both:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33162
163----------------
164$ git bundle create mybundle v1.0.0..master
165----------------
166
Junio C Hamano1de75722009-03-26 08:39:38167You can use a basis based on time:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33168
169----------------
170$ git bundle create mybundle --since=10.days master
171----------------
172
Junio C Hamano1de75722009-03-26 08:39:38173You can use the number of commits:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33174
175----------------
176$ git bundle create mybundle -10 master
177----------------
178
179You can run `git-bundle verify` to see if you can extract from a bundle
Junio C Hamano1de75722009-03-26 08:39:38180that was created with a basis:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33181
182----------------
183$ git bundle verify mybundle
184----------------
185
186This will list what commits you must have in order to extract from the
Junio C Hamano1de75722009-03-26 08:39:38187bundle and will error out if you do not have them.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33188
189A bundle from a recipient repository's point of view is just like a
Junio C Hamano1de75722009-03-26 08:39:38190regular repository which it fetches or pulls from. You can, for example, map
191references when fetching:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33192
193----------------
194$ git fetch mybundle master:localRef
195----------------
196
Junio C Hamano1de75722009-03-26 08:39:38197You can also see what references it offers.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33198
199----------------
200$ git ls-remote mybundle
201----------------
Junio C Hamano6ac2f142007-03-01 01:24:56202
203Author
204------
205Written by Mark Levedahl <mdl123@verizon.net>
206
207GIT
208---
Junio C Hamanof7c042d2008-06-06 22:50:53209Part of the linkgit:git[1] suite