blob: 92b01ec25d147831afaa0ffa43e11549af69e18c [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 Hamano2db3e752010-09-03 21:33:0612'git bundle' create <file> <git-rev-list-args>
Junio C Hamanofce7c7e2008-07-02 03:06:3813'git bundle' verify <file>
Junio C Hamanod2179ef2010-10-22 04:12:1714'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 Hamano1aa40d22010-01-21 17:46:4324'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 Hamano1aa40d22010-01-21 17:46:4326another 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>::
Junio C Hamano2db3e752010-09-03 21:33:0637Used to create a bundle named 'file'. This requires the
38'git-rev-list-args' arguments to define the bundle contents.
Junio C Hamano6ac2f142007-03-01 01:24:5639
40verify <file>::
Junio C Hamano2db3e752010-09-03 21:33:0641Used to check that a bundle file is valid and will apply
42cleanly to the current repository. This includes checks on the
43bundle format itself as well as checking that the prerequisite
44commits exist and are fully linked in the current repository.
45'git bundle' prints a list of missing commits, if any, and exits
46with a non-zero status.
Junio C Hamano6ac2f142007-03-01 01:24:5647
48list-heads <file>::
Junio C Hamano2db3e752010-09-03 21:33:0649Lists the references defined in the bundle. If followed by a
50list of references, only references matching those given are
51printed out.
Junio C Hamano6ac2f142007-03-01 01:24:5652
53unbundle <file>::
Junio C Hamano2db3e752010-09-03 21:33:0654Passes the objects in the bundle to 'git index-pack'
55for storage in the repository, then prints the names of all
56defined references. If a list of references is given, only
57references matching those in the list are printed. This command is
58really plumbing, intended to be called only by 'git fetch'.
Junio C Hamano6ac2f142007-03-01 01:24:5659
Junio C Hamano2db3e752010-09-03 21:33:0660<git-rev-list-args>::
61A list of arguments, acceptable to 'git rev-parse' and
Junio C Hamano7165bf72011-01-04 22:06:1862'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES
Junio C Hamano2db3e752010-09-03 21:33:0663below), that specifies the specific objects and references
64to transport. For example, `master{tilde}10..master` causes the
65current master reference to be packaged along with all objects
66added since its 10th ancestor commit. There is no explicit
67limit to the number of references and objects that may be
68packaged.
Junio C Hamano6ac2f142007-03-01 01:24:5669
70
Junio C Hamanod2179ef2010-10-22 04:12:1771[<refname>...]::
Junio C Hamano2db3e752010-09-03 21:33:0672A list of references used to limit the references reported as
73available. This is principally of use to 'git fetch', which
74expects to receive only those references asked for and not
75necessarily everything in the pack (in this case, 'git bundle' acts
76like 'git fetch-pack').
Junio C Hamano6ac2f142007-03-01 01:24:5677
78SPECIFYING REFERENCES
79---------------------
80
Junio C Hamano1aa40d22010-01-21 17:46:4381'git bundle' will only package references that are shown by
82'git show-ref': this includes heads, tags, and remote heads. References
Junio C Hamano2db3e752010-09-03 21:33:0683such as `master{tilde}1` cannot be packaged, but are perfectly suitable for
Junio C Hamano6ac2f142007-03-01 01:24:5684defining the basis. More than one reference may be packaged, and more
85than one basis can be specified. The objects packaged are those not
86contained in the union of the given bases. Each basis can be
Junio C Hamano2db3e752010-09-03 21:33:0687specified explicitly (e.g. `^master{tilde}10`), or implicitly (e.g.
88`master{tilde}10..master`, `--since=10.days.ago master`).
Junio C Hamano6ac2f142007-03-01 01:24:5689
90It is very important that the basis used be held by the destination.
Junio C Hamano1de75722009-03-26 08:39:3891It is okay to err on the side of caution, causing the bundle file
92to contain objects already in the destination, as these are ignored
Junio C Hamano6ac2f142007-03-01 01:24:5693when unpacking at the destination.
94
95EXAMPLE
96-------
97
Junio C Hamanoa3bb6eb2009-02-05 01:26:3398Assume you want to transfer the history from a repository R1 on machine A
99to another repository R2 on machine B.
Junio C Hamano6ac2f142007-03-01 01:24:56100For whatever reason, direct connection between A and B is not allowed,
Junio C Hamano1de75722009-03-26 08:39:38101but we can move data from A to B via some mechanism (CD, email, etc.).
102We want to update R2 with development made on the branch master in R1.
Junio C Hamano601f3e52008-02-25 08:40:42103
Junio C Hamano1de75722009-03-26 08:39:38104To bootstrap the process, you can first create a bundle that does not have
105any basis. You can use a tag to remember up to what commit you last
106processed, in order to make it easy to later update the other repository
107with an incremental bundle:
Junio C Hamano601f3e52008-02-25 08:40:42108
Junio C Hamanoa3bb6eb2009-02-05 01:26:33109----------------
110machineA$ cd R1
Junio C Hamano61169122009-02-09 18:05:49111machineA$ git bundle create file.bundle master
Junio C Hamanoa3bb6eb2009-02-05 01:26:33112machineA$ git tag -f lastR2bundle master
113----------------
Junio C Hamano601f3e52008-02-25 08:40:42114
Junio C Hamano1de75722009-03-26 08:39:38115Then you transfer file.bundle to the target machine B. If you are creating
116the repository on machine B, then you can clone from the bundle as if it
117were a remote repository instead of creating an empty repository and then
118pulling or fetching objects from the bundle:
Junio C Hamano601f3e52008-02-25 08:40:42119
Junio C Hamanoa3bb6eb2009-02-05 01:26:33120----------------
Junio C Hamano61169122009-02-09 18:05:49121machineB$ git clone /home/me/tmp/file.bundle R2
Junio C Hamanoa3bb6eb2009-02-05 01:26:33122----------------
Junio C Hamano6ac2f142007-03-01 01:24:56123
Junio C Hamanoa3bb6eb2009-02-05 01:26:33124This will define a remote called "origin" in the resulting repository that
Junio C Hamano1de75722009-03-26 08:39:38125lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
Junio C Hamanoa3bb6eb2009-02-05 01:26:33126have an entry like this:
Junio C Hamano6ac2f142007-03-01 01:24:56127
Junio C Hamano601f3e52008-02-25 08:40:42128------------------------
Junio C Hamanoa3bb6eb2009-02-05 01:26:33129[remote "origin"]
Junio C Hamano61169122009-02-09 18:05:49130 url = /home/me/tmp/file.bundle
Junio C Hamano6ac2f142007-03-01 01:24:56131 fetch = refs/heads/*:refs/remotes/origin/*
Junio C Hamano601f3e52008-02-25 08:40:42132------------------------
Junio C Hamano6ac2f142007-03-01 01:24:56133
Junio C Hamano1de75722009-03-26 08:39:38134To update the resulting mine.git repository, you can fetch or pull after
135replacing the bundle stored at /home/me/tmp/file.bundle with incremental
136updates.
Junio C Hamano6ac2f142007-03-01 01:24:56137
Junio C Hamano1de75722009-03-26 08:39:38138After working some more in the original repository, you can create an
139incremental bundle to update the other repository:
Junio C Hamano6ac2f142007-03-01 01:24:56140
Junio C Hamanoa3bb6eb2009-02-05 01:26:33141----------------
142machineA$ cd R1
Junio C Hamano61169122009-02-09 18:05:49143machineA$ git bundle create file.bundle lastR2bundle..master
Junio C Hamanoa3bb6eb2009-02-05 01:26:33144machineA$ git tag -f lastR2bundle master
145----------------
146
Junio C Hamano1de75722009-03-26 08:39:38147You then transfer the bundle to the other machine to replace
148/home/me/tmp/file.bundle, and pull from it.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33149
150----------------
151machineB$ cd R2
152machineB$ git pull
153----------------
154
155If you know up to what commit the intended recipient repository should
Junio C Hamano1de75722009-03-26 08:39:38156have the necessary objects, you can use that knowledge to specify the
Junio C Hamanoa3bb6eb2009-02-05 01:26:33157basis, giving a cut-off point to limit the revisions and objects that go
Junio C Hamano2db3e752010-09-03 21:33:06158in the resulting bundle. The previous example used the lastR2bundle tag
Junio C Hamano1de75722009-03-26 08:39:38159for this purpose, but you can use any other options that you would give to
Junio C Hamanoa3bb6eb2009-02-05 01:26:33160the linkgit:git-log[1] command. Here are more examples:
161
Junio C Hamano1de75722009-03-26 08:39:38162You can use a tag that is present in both:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33163
164----------------
165$ git bundle create mybundle v1.0.0..master
166----------------
167
Junio C Hamano1de75722009-03-26 08:39:38168You can use a basis based on time:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33169
170----------------
171$ git bundle create mybundle --since=10.days master
172----------------
173
Junio C Hamano1de75722009-03-26 08:39:38174You can use the number of commits:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33175
176----------------
177$ git bundle create mybundle -10 master
178----------------
179
180You can run `git-bundle verify` to see if you can extract from a bundle
Junio C Hamano1de75722009-03-26 08:39:38181that was created with a basis:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33182
183----------------
184$ git bundle verify mybundle
185----------------
186
187This will list what commits you must have in order to extract from the
Junio C Hamano1de75722009-03-26 08:39:38188bundle and will error out if you do not have them.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33189
190A bundle from a recipient repository's point of view is just like a
Junio C Hamano1de75722009-03-26 08:39:38191regular repository which it fetches or pulls from. You can, for example, map
192references when fetching:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33193
194----------------
195$ git fetch mybundle master:localRef
196----------------
197
Junio C Hamano2db3e752010-09-03 21:33:06198You can also see what references it offers:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33199
200----------------
201$ git ls-remote mybundle
202----------------
Junio C Hamano6ac2f142007-03-01 01:24:56203
Junio C Hamano6ac2f142007-03-01 01:24:56204GIT
205---
Junio C Hamanof7c042d2008-06-06 22:50:53206Part of the linkgit:git[1] suite