Fourth batch
[git/raj.git] / Documentation / git-bundle.txt
blobd34b0964be17b88ae6798aed46ca518a97aceea1
1 git-bundle(1)
2 =============
4 NAME
5 ----
6 git-bundle - Move objects and refs by archive
9 SYNOPSIS
10 --------
11 [verse]
12 'git bundle' create [-q | --quiet | --progress | --all-progress] [--all-progress-implied] <file> <git-rev-list-args>
13 'git bundle' verify [-q | --quiet] <file>
14 'git bundle' list-heads <file> [<refname>...]
15 'git bundle' unbundle <file> [<refname>...]
17 DESCRIPTION
18 -----------
20 Some workflows require that one or more branches of development on one
21 machine be replicated on another machine, but the two machines cannot
22 be directly connected, and therefore the interactive Git protocols (git,
23 ssh, http) cannot be used.
25 The 'git bundle' command packages objects and references in an archive
26 at the originating machine, which can then be imported into another
27 repository using 'git fetch', 'git pull', or 'git clone',
28 after moving the archive by some means (e.g., by sneakernet).
30 As no
31 direct connection between the repositories exists, the user must specify a
32 basis for the bundle that is held by the destination repository: the
33 bundle assumes that all objects in the basis are already in the
34 destination repository.
36 OPTIONS
37 -------
39 create [options] <file> <git-rev-list-args>::
40         Used to create a bundle named 'file'.  This requires the
41         '<git-rev-list-args>' arguments to define the bundle contents.
42         'options' contains the options specific to the 'git bundle create'
43         subcommand.
45 verify <file>::
46         Used to check that a bundle file is valid and will apply
47         cleanly to the current repository.  This includes checks on the
48         bundle format itself as well as checking that the prerequisite
49         commits exist and are fully linked in the current repository.
50         'git bundle' prints a list of missing commits, if any, and exits
51         with a non-zero status.
53 list-heads <file>::
54         Lists the references defined in the bundle.  If followed by a
55         list of references, only references matching those given are
56         printed out.
58 unbundle <file>::
59         Passes the objects in the bundle to 'git index-pack'
60         for storage in the repository, then prints the names of all
61         defined references. If a list of references is given, only
62         references matching those in the list are printed. This command is
63         really plumbing, intended to be called only by 'git fetch'.
65 <git-rev-list-args>::
66         A list of arguments, acceptable to 'git rev-parse' and
67         'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES
68         below), that specifies the specific objects and references
69         to transport.  For example, `master~10..master` causes the
70         current master reference to be packaged along with all objects
71         added since its 10th ancestor commit.  There is no explicit
72         limit to the number of references and objects that may be
73         packaged.
76 [<refname>...]::
77         A list of references used to limit the references reported as
78         available. This is principally of use to 'git fetch', which
79         expects to receive only those references asked for and not
80         necessarily everything in the pack (in this case, 'git bundle' acts
81         like 'git fetch-pack').
83 --progress::
84         Progress status is reported on the standard error stream
85         by default when it is attached to a terminal, unless -q
86         is specified. This flag forces progress status even if
87         the standard error stream is not directed to a terminal.
89 --all-progress::
90         When --stdout is specified then progress report is
91         displayed during the object count and compression phases
92         but inhibited during the write-out phase. The reason is
93         that in some cases the output stream is directly linked
94         to another command which may wish to display progress
95         status of its own as it processes incoming pack data.
96         This flag is like --progress except that it forces progress
97         report for the write-out phase as well even if --stdout is
98         used.
100 --all-progress-implied::
101         This is used to imply --all-progress whenever progress display
102         is activated.  Unlike --all-progress this flag doesn't actually
103         force any progress display by itself.
105 -q::
106 --quiet::
107         This flag makes the command not to report its progress
108         on the standard error stream.
110 SPECIFYING REFERENCES
111 ---------------------
113 'git bundle' will only package references that are shown by
114 'git show-ref': this includes heads, tags, and remote heads.  References
115 such as `master~1` cannot be packaged, but are perfectly suitable for
116 defining the basis.  More than one reference may be packaged, and more
117 than one basis can be specified.  The objects packaged are those not
118 contained in the union of the given bases.  Each basis can be
119 specified explicitly (e.g. `^master~10`), or implicitly (e.g.
120 `master~10..master`, `--since=10.days.ago master`).
122 It is very important that the basis used be held by the destination.
123 It is okay to err on the side of caution, causing the bundle file
124 to contain objects already in the destination, as these are ignored
125 when unpacking at the destination.
127 `git clone` can use any bundle created without negative refspecs
128 (e.g., `new`, but not `old..new`).
129 If you want to match `git clone --mirror`, which would include your
130 refs such as `refs/remotes/*`, use `--all`.
131 If you want to provide the same set of refs that a clone directly
132 from the source repository would get, use `--branches --tags` for
133 the `<git-rev-list-args>`.
135 EXAMPLES
136 --------
138 Assume you want to transfer the history from a repository R1 on machine A
139 to another repository R2 on machine B.
140 For whatever reason, direct connection between A and B is not allowed,
141 but we can move data from A to B via some mechanism (CD, email, etc.).
142 We want to update R2 with development made on the branch master in R1.
144 To bootstrap the process, you can first create a bundle that does not have
145 any basis. You can use a tag to remember up to what commit you last
146 processed, in order to make it easy to later update the other repository
147 with an incremental bundle:
149 ----------------
150 machineA$ cd R1
151 machineA$ git bundle create file.bundle master
152 machineA$ git tag -f lastR2bundle master
153 ----------------
155 Then you transfer file.bundle to the target machine B. Because this
156 bundle does not require any existing object to be extracted, you can
157 create a new repository on machine B by cloning from it:
159 ----------------
160 machineB$ git clone -b master /home/me/tmp/file.bundle R2
161 ----------------
163 This will define a remote called "origin" in the resulting repository that
164 lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
165 have an entry like this:
167 ------------------------
168 [remote "origin"]
169     url = /home/me/tmp/file.bundle
170     fetch = refs/heads/*:refs/remotes/origin/*
171 ------------------------
173 To update the resulting mine.git repository, you can fetch or pull after
174 replacing the bundle stored at /home/me/tmp/file.bundle with incremental
175 updates.
177 After working some more in the original repository, you can create an
178 incremental bundle to update the other repository:
180 ----------------
181 machineA$ cd R1
182 machineA$ git bundle create file.bundle lastR2bundle..master
183 machineA$ git tag -f lastR2bundle master
184 ----------------
186 You then transfer the bundle to the other machine to replace
187 /home/me/tmp/file.bundle, and pull from it.
189 ----------------
190 machineB$ cd R2
191 machineB$ git pull
192 ----------------
194 If you know up to what commit the intended recipient repository should
195 have the necessary objects, you can use that knowledge to specify the
196 basis, giving a cut-off point to limit the revisions and objects that go
197 in the resulting bundle. The previous example used the lastR2bundle tag
198 for this purpose, but you can use any other options that you would give to
199 the linkgit:git-log[1] command. Here are more examples:
201 You can use a tag that is present in both:
203 ----------------
204 $ git bundle create mybundle v1.0.0..master
205 ----------------
207 You can use a basis based on time:
209 ----------------
210 $ git bundle create mybundle --since=10.days master
211 ----------------
213 You can use the number of commits:
215 ----------------
216 $ git bundle create mybundle -10 master
217 ----------------
219 You can run `git-bundle verify` to see if you can extract from a bundle
220 that was created with a basis:
222 ----------------
223 $ git bundle verify mybundle
224 ----------------
226 This will list what commits you must have in order to extract from the
227 bundle and will error out if you do not have them.
229 A bundle from a recipient repository's point of view is just like a
230 regular repository which it fetches or pulls from. You can, for example, map
231 references when fetching:
233 ----------------
234 $ git fetch mybundle master:localRef
235 ----------------
237 You can also see what references it offers:
239 ----------------
240 $ git ls-remote mybundle
241 ----------------
245 Part of the linkgit:git[1] suite