blob: ccada80a4a4c9813804372b7b167f0015a7ec3a7 [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 Hamano8ef91f32019-12-01 22:58:2712'git bundle' create [-q | --quiet | --progress | --all-progress] [--all-progress-implied] <file> <git-rev-list-args>
13'git bundle' verify [-q | --quiet] <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 Hamano076ffcc2013-02-06 05:13:2122be directly connected, and therefore the interactive Git protocols (git,
Junio C Hamanof85ef632016-02-17 22:31:0623ssh, 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
Junio C Hamano8ef91f32019-12-01 22:58:2736create [options] <file> <git-rev-list-args>::
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 Hamano8ef91f32019-12-01 22:58:2739'options' contains the options specific to the 'git bundle create'
40subcommand.
Junio C Hamano6ac2f142007-03-01 01:24:5641
42verify <file>::
Junio C Hamano2db3e752010-09-03 21:33:0643Used to check that a bundle file is valid and will apply
44cleanly to the current repository. This includes checks on the
45bundle format itself as well as checking that the prerequisite
46commits exist and are fully linked in the current repository.
47'git bundle' prints a list of missing commits, if any, and exits
48with a non-zero status.
Junio C Hamano6ac2f142007-03-01 01:24:5649
50list-heads <file>::
Junio C Hamano2db3e752010-09-03 21:33:0651Lists the references defined in the bundle. If followed by a
52list of references, only references matching those given are
53printed out.
Junio C Hamano6ac2f142007-03-01 01:24:5654
55unbundle <file>::
Junio C Hamano2db3e752010-09-03 21:33:0656Passes the objects in the bundle to 'git index-pack'
57for storage in the repository, then prints the names of all
58defined references. If a list of references is given, only
59references matching those in the list are printed. This command is
60really plumbing, intended to be called only by 'git fetch'.
Junio C Hamano6ac2f142007-03-01 01:24:5661
Junio C Hamano2db3e752010-09-03 21:33:0662<git-rev-list-args>::
63A list of arguments, acceptable to 'git rev-parse' and
Junio C Hamano7165bf72011-01-04 22:06:1864'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES
Junio C Hamano2db3e752010-09-03 21:33:0665below), that specifies the specific objects and references
Junio C Hamanob76a6862012-05-02 22:02:4666to transport. For example, `master~10..master` causes the
Junio C Hamano2db3e752010-09-03 21:33:0667current master reference to be packaged along with all objects
68added since its 10th ancestor commit. There is no explicit
69limit to the number of references and objects that may be
70packaged.
Junio C Hamano6ac2f142007-03-01 01:24:5671
72
Junio C Hamanod2179ef2010-10-22 04:12:1773[<refname>...]::
Junio C Hamano2db3e752010-09-03 21:33:0674A list of references used to limit the references reported as
75available. This is principally of use to 'git fetch', which
76expects to receive only those references asked for and not
77necessarily everything in the pack (in this case, 'git bundle' acts
78like 'git fetch-pack').
Junio C Hamano6ac2f142007-03-01 01:24:5679
Junio C Hamano8ef91f32019-12-01 22:58:2780--progress::
81Progress status is reported on the standard error stream
82by default when it is attached to a terminal, unless -q
83is specified. This flag forces progress status even if
84the standard error stream is not directed to a terminal.
85
86--all-progress::
87When --stdout is specified then progress report is
88displayed during the object count and compression phases
89but inhibited during the write-out phase. The reason is
90that in some cases the output stream is directly linked
91to another command which may wish to display progress
92status of its own as it processes incoming pack data.
93This flag is like --progress except that it forces progress
94report for the write-out phase as well even if --stdout is
95used.
96
97--all-progress-implied::
98This is used to imply --all-progress whenever progress display
99is activated. Unlike --all-progress this flag doesn't actually
100force any progress display by itself.
101
102-q::
103--quiet::
104This flag makes the command not to report its progress
105on the standard error stream.
106
Junio C Hamano6ac2f142007-03-01 01:24:56107SPECIFYING REFERENCES
108---------------------
109
Junio C Hamano1aa40d22010-01-21 17:46:43110'git bundle' will only package references that are shown by
111'git show-ref': this includes heads, tags, and remote heads. References
Junio C Hamanob76a6862012-05-02 22:02:46112such as `master~1` cannot be packaged, but are perfectly suitable for
Junio C Hamano6ac2f142007-03-01 01:24:56113defining the basis. More than one reference may be packaged, and more
114than one basis can be specified. The objects packaged are those not
115contained in the union of the given bases. Each basis can be
Junio C Hamanob76a6862012-05-02 22:02:46116specified explicitly (e.g. `^master~10`), or implicitly (e.g.
117`master~10..master`, `--since=10.days.ago master`).
Junio C Hamano6ac2f142007-03-01 01:24:56118
119It is very important that the basis used be held by the destination.
Junio C Hamano1de75722009-03-26 08:39:38120It is okay to err on the side of caution, causing the bundle file
121to contain objects already in the destination, as these are ignored
Junio C Hamano6ac2f142007-03-01 01:24:56122when unpacking at the destination.
123
Junio C Hamanob9d9d902018-05-23 07:07:42124EXAMPLES
125--------
Junio C Hamano6ac2f142007-03-01 01:24:56126
Junio C Hamanoa3bb6eb2009-02-05 01:26:33127Assume you want to transfer the history from a repository R1 on machine A
128to another repository R2 on machine B.
Junio C Hamano6ac2f142007-03-01 01:24:56129For whatever reason, direct connection between A and B is not allowed,
Junio C Hamano1de75722009-03-26 08:39:38130but we can move data from A to B via some mechanism (CD, email, etc.).
131We want to update R2 with development made on the branch master in R1.
Junio C Hamano601f3e52008-02-25 08:40:42132
Junio C Hamano1de75722009-03-26 08:39:38133To bootstrap the process, you can first create a bundle that does not have
134any basis. You can use a tag to remember up to what commit you last
135processed, in order to make it easy to later update the other repository
136with an incremental bundle:
Junio C Hamano601f3e52008-02-25 08:40:42137
Junio C Hamanoa3bb6eb2009-02-05 01:26:33138----------------
139machineA$ cd R1
Junio C Hamano61169122009-02-09 18:05:49140machineA$ git bundle create file.bundle master
Junio C Hamanoa3bb6eb2009-02-05 01:26:33141machineA$ git tag -f lastR2bundle master
142----------------
Junio C Hamano601f3e52008-02-25 08:40:42143
Junio C Hamano6bdcc7d2013-01-09 00:15:42144Then you transfer file.bundle to the target machine B. Because this
145bundle does not require any existing object to be extracted, you can
146create a new repository on machine B by cloning from it:
Junio C Hamano601f3e52008-02-25 08:40:42147
Junio C Hamanoa3bb6eb2009-02-05 01:26:33148----------------
Junio C Hamano6bdcc7d2013-01-09 00:15:42149machineB$ git clone -b master /home/me/tmp/file.bundle R2
Junio C Hamanoa3bb6eb2009-02-05 01:26:33150----------------
Junio C Hamano6ac2f142007-03-01 01:24:56151
Junio C Hamanoa3bb6eb2009-02-05 01:26:33152This will define a remote called "origin" in the resulting repository that
Junio C Hamano1de75722009-03-26 08:39:38153lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will
Junio C Hamanoa3bb6eb2009-02-05 01:26:33154have an entry like this:
Junio C Hamano6ac2f142007-03-01 01:24:56155
Junio C Hamano601f3e52008-02-25 08:40:42156------------------------
Junio C Hamanoa3bb6eb2009-02-05 01:26:33157[remote "origin"]
Junio C Hamano61169122009-02-09 18:05:49158 url = /home/me/tmp/file.bundle
Junio C Hamano6ac2f142007-03-01 01:24:56159 fetch = refs/heads/*:refs/remotes/origin/*
Junio C Hamano601f3e52008-02-25 08:40:42160------------------------
Junio C Hamano6ac2f142007-03-01 01:24:56161
Junio C Hamano1de75722009-03-26 08:39:38162To update the resulting mine.git repository, you can fetch or pull after
163replacing the bundle stored at /home/me/tmp/file.bundle with incremental
164updates.
Junio C Hamano6ac2f142007-03-01 01:24:56165
Junio C Hamano1de75722009-03-26 08:39:38166After working some more in the original repository, you can create an
167incremental bundle to update the other repository:
Junio C Hamano6ac2f142007-03-01 01:24:56168
Junio C Hamanoa3bb6eb2009-02-05 01:26:33169----------------
170machineA$ cd R1
Junio C Hamano61169122009-02-09 18:05:49171machineA$ git bundle create file.bundle lastR2bundle..master
Junio C Hamanoa3bb6eb2009-02-05 01:26:33172machineA$ git tag -f lastR2bundle master
173----------------
174
Junio C Hamano1de75722009-03-26 08:39:38175You then transfer the bundle to the other machine to replace
176/home/me/tmp/file.bundle, and pull from it.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33177
178----------------
179machineB$ cd R2
180machineB$ git pull
181----------------
182
183If you know up to what commit the intended recipient repository should
Junio C Hamano1de75722009-03-26 08:39:38184have the necessary objects, you can use that knowledge to specify the
Junio C Hamanoa3bb6eb2009-02-05 01:26:33185basis, giving a cut-off point to limit the revisions and objects that go
Junio C Hamano2db3e752010-09-03 21:33:06186in the resulting bundle. The previous example used the lastR2bundle tag
Junio C Hamano1de75722009-03-26 08:39:38187for this purpose, but you can use any other options that you would give to
Junio C Hamanoa3bb6eb2009-02-05 01:26:33188the linkgit:git-log[1] command. Here are more examples:
189
Junio C Hamano1de75722009-03-26 08:39:38190You can use a tag that is present in both:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33191
192----------------
193$ git bundle create mybundle v1.0.0..master
194----------------
195
Junio C Hamano1de75722009-03-26 08:39:38196You can use a basis based on time:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33197
198----------------
199$ git bundle create mybundle --since=10.days master
200----------------
201
Junio C Hamano1de75722009-03-26 08:39:38202You can use the number of commits:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33203
204----------------
205$ git bundle create mybundle -10 master
206----------------
207
208You can run `git-bundle verify` to see if you can extract from a bundle
Junio C Hamano1de75722009-03-26 08:39:38209that was created with a basis:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33210
211----------------
212$ git bundle verify mybundle
213----------------
214
215This will list what commits you must have in order to extract from the
Junio C Hamano1de75722009-03-26 08:39:38216bundle and will error out if you do not have them.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33217
218A bundle from a recipient repository's point of view is just like a
Junio C Hamano1de75722009-03-26 08:39:38219regular repository which it fetches or pulls from. You can, for example, map
220references when fetching:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33221
222----------------
223$ git fetch mybundle master:localRef
224----------------
225
Junio C Hamano2db3e752010-09-03 21:33:06226You can also see what references it offers:
Junio C Hamanoa3bb6eb2009-02-05 01:26:33227
228----------------
229$ git ls-remote mybundle
230----------------
Junio C Hamano6ac2f142007-03-01 01:24:56231
Junio C Hamano6ac2f142007-03-01 01:24:56232GIT
233---
Junio C Hamanof7c042d2008-06-06 22:50:53234Part of the linkgit:git[1] suite