updated git doc
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-bundle.xml
blobc81ced2b9d78c773a880752ade8e18bafa74d32c
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-bundle(1)">\r
5 <articleinfo>\r
6     <title>git-bundle(1)</title>\r
7 <indexterm>\r
8 <primary>git-bundle(1)</primary>\r
9 </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-bundle - Move objects and refs by archive</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git bundle</emphasis> create &lt;file&gt; &lt;git-rev-list-args&gt;\r
19 <emphasis>git bundle</emphasis> verify &lt;file&gt;\r
20 <emphasis>git bundle</emphasis> list-heads &lt;file&gt; [&lt;refname&gt;&#8230;]\r
21 <emphasis>git bundle</emphasis> unbundle &lt;file&gt; [&lt;refname&gt;&#8230;]</literallayout>\r
22 </blockquote>\r
23 </simplesect>\r
24 <simplesect id="_description">\r
25 <title>DESCRIPTION</title>\r
26 <simpara>Some workflows require that one or more branches of development on one\r
27 machine be replicated on another machine, but the two machines cannot\r
28 be directly connected, and therefore the interactive git protocols (git,\r
29 ssh, rsync, http) cannot be used.  This command provides support for\r
30 <emphasis>git fetch</emphasis> and <emphasis>git pull</emphasis> to operate by packaging objects and references\r
31 in an archive at the originating machine, then importing those into\r
32 another repository using <emphasis>git fetch</emphasis> and <emphasis>git pull</emphasis>\r
33 after moving the archive by some means (e.g., by sneakernet).  As no\r
34 direct connection between the repositories exists, the user must specify a\r
35 basis for the bundle that is held by the destination repository: the\r
36 bundle assumes that all objects in the basis are already in the\r
37 destination repository.</simpara>\r
38 </simplesect>\r
39 <simplesect id="_options">\r
40 <title>OPTIONS</title>\r
41 <variablelist>\r
42 <varlistentry>\r
43 <term>\r
44 create &lt;file&gt;\r
45 </term>\r
46 <listitem>\r
47 <simpara>\r
48         Used to create a bundle named <emphasis>file</emphasis>.  This requires the\r
49         <emphasis>git-rev-list-args</emphasis> arguments to define the bundle contents.\r
50 </simpara>\r
51 </listitem>\r
52 </varlistentry>\r
53 <varlistentry>\r
54 <term>\r
55 verify &lt;file&gt;\r
56 </term>\r
57 <listitem>\r
58 <simpara>\r
59         Used to check that a bundle file is valid and will apply\r
60         cleanly to the current repository.  This includes checks on the\r
61         bundle format itself as well as checking that the prerequisite\r
62         commits exist and are fully linked in the current repository.\r
63         <emphasis>git bundle</emphasis> prints a list of missing commits, if any, and exits\r
64         with a non-zero status.\r
65 </simpara>\r
66 </listitem>\r
67 </varlistentry>\r
68 <varlistentry>\r
69 <term>\r
70 list-heads &lt;file&gt;\r
71 </term>\r
72 <listitem>\r
73 <simpara>\r
74         Lists the references defined in the bundle.  If followed by a\r
75         list of references, only references matching those given are\r
76         printed out.\r
77 </simpara>\r
78 </listitem>\r
79 </varlistentry>\r
80 <varlistentry>\r
81 <term>\r
82 unbundle &lt;file&gt;\r
83 </term>\r
84 <listitem>\r
85 <simpara>\r
86         Passes the objects in the bundle to <emphasis>git index-pack</emphasis>\r
87         for storage in the repository, then prints the names of all\r
88         defined references. If a list of references is given, only\r
89         references matching those in the list are printed. This command is\r
90         really plumbing, intended to be called only by <emphasis>git fetch</emphasis>.\r
91 </simpara>\r
92 </listitem>\r
93 </varlistentry>\r
94 <varlistentry>\r
95 <term>\r
96 &lt;git-rev-list-args&gt;\r
97 </term>\r
98 <listitem>\r
99 <simpara>\r
100         A list of arguments, acceptable to <emphasis>git rev-parse</emphasis> and\r
101         <emphasis>git rev-list</emphasis> (and containing a named ref, see SPECIFYING REFERENCES\r
102         below), that specifies the specific objects and references\r
103         to transport.  For example, <emphasis>master~10..master</emphasis> causes the\r
104         current master reference to be packaged along with all objects\r
105         added since its 10th ancestor commit.  There is no explicit\r
106         limit to the number of references and objects that may be\r
107         packaged.\r
108 </simpara>\r
109 </listitem>\r
110 </varlistentry>\r
111 <varlistentry>\r
112 <term>\r
113 [&lt;refname&gt;&#8230;]\r
114 </term>\r
115 <listitem>\r
116 <simpara>\r
117         A list of references used to limit the references reported as\r
118         available. This is principally of use to <emphasis>git fetch</emphasis>, which\r
119         expects to receive only those references asked for and not\r
120         necessarily everything in the pack (in this case, <emphasis>git bundle</emphasis> acts\r
121         like <emphasis>git fetch-pack</emphasis>).\r
122 </simpara>\r
123 </listitem>\r
124 </varlistentry>\r
125 </variablelist>\r
126 </simplesect>\r
127 <simplesect id="_specifying_references">\r
128 <title>SPECIFYING REFERENCES</title>\r
129 <simpara><emphasis>git bundle</emphasis> will only package references that are shown by\r
130 <emphasis>git show-ref</emphasis>: this includes heads, tags, and remote heads.  References\r
131 such as <emphasis>master~1</emphasis> cannot be packaged, but are perfectly suitable for\r
132 defining the basis.  More than one reference may be packaged, and more\r
133 than one basis can be specified.  The objects packaged are those not\r
134 contained in the union of the given bases.  Each basis can be\r
135 specified explicitly (e.g. <emphasis>^master~10</emphasis>), or implicitly (e.g.\r
136 <emphasis>master~10..master</emphasis>, <emphasis>--since=10.days.ago master</emphasis>).</simpara>\r
137 <simpara>It is very important that the basis used be held by the destination.\r
138 It is okay to err on the side of caution, causing the bundle file\r
139 to contain objects already in the destination, as these are ignored\r
140 when unpacking at the destination.</simpara>\r
141 </simplesect>\r
142 <simplesect id="_example">\r
143 <title>EXAMPLE</title>\r
144 <simpara>Assume you want to transfer the history from a repository R1 on machine A\r
145 to another repository R2 on machine B.\r
146 For whatever reason, direct connection between A and B is not allowed,\r
147 but we can move data from A to B via some mechanism (CD, email, etc.).\r
148 We want to update R2 with development made on the branch master in R1.</simpara>\r
149 <simpara>To bootstrap the process, you can first create a bundle that does not have\r
150 any basis. You can use a tag to remember up to what commit you last\r
151 processed, in order to make it easy to later update the other repository\r
152 with an incremental bundle:</simpara>\r
153 <screen>machineA$ cd R1\r
154 machineA$ git bundle create file.bundle master\r
155 machineA$ git tag -f lastR2bundle master</screen>\r
156 <simpara>Then you transfer file.bundle to the target machine B. If you are creating\r
157 the repository on machine B, then you can clone from the bundle as if it\r
158 were a remote repository instead of creating an empty repository and then\r
159 pulling or fetching objects from the bundle:</simpara>\r
160 <screen>machineB$ git clone /home/me/tmp/file.bundle R2</screen>\r
161 <simpara>This will define a remote called "origin" in the resulting repository that\r
162 lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will\r
163 have an entry like this:</simpara>\r
164 <screen>[remote "origin"]\r
165     url = /home/me/tmp/file.bundle\r
166     fetch = refs/heads/*:refs/remotes/origin/*</screen>\r
167 <simpara>To update the resulting mine.git repository, you can fetch or pull after\r
168 replacing the bundle stored at /home/me/tmp/file.bundle with incremental\r
169 updates.</simpara>\r
170 <simpara>After working some more in the original repository, you can create an\r
171 incremental bundle to update the other repository:</simpara>\r
172 <screen>machineA$ cd R1\r
173 machineA$ git bundle create file.bundle lastR2bundle..master\r
174 machineA$ git tag -f lastR2bundle master</screen>\r
175 <simpara>You then transfer the bundle to the other machine to replace\r
176 /home/me/tmp/file.bundle, and pull from it.</simpara>\r
177 <screen>machineB$ cd R2\r
178 machineB$ git pull</screen>\r
179 <simpara>If you know up to what commit the intended recipient repository should\r
180 have the necessary objects, you can use that knowledge to specify the\r
181 basis, giving a cut-off point to limit the revisions and objects that go\r
182 in the resulting bundle. The previous example used the lastR2bundle tag\r
183 for this purpose, but you can use any other options that you would give to\r
184 the <xref linkend="git-log(1)" /> command. Here are more examples:</simpara>\r
185 <simpara>You can use a tag that is present in both:</simpara>\r
186 <screen>$ git bundle create mybundle v1.0.0..master</screen>\r
187 <simpara>You can use a basis based on time:</simpara>\r
188 <screen>$ git bundle create mybundle --since=10.days master</screen>\r
189 <simpara>You can use the number of commits:</simpara>\r
190 <screen>$ git bundle create mybundle -10 master</screen>\r
191 <simpara>You can run <emphasis>git-bundle verify</emphasis> to see if you can extract from a bundle\r
192 that was created with a basis:</simpara>\r
193 <screen>$ git bundle verify mybundle</screen>\r
194 <simpara>This will list what commits you must have in order to extract from the\r
195 bundle and will error out if you do not have them.</simpara>\r
196 <simpara>A bundle from a recipient repository's point of view is just like a\r
197 regular repository which it fetches or pulls from. You can, for example, map\r
198 references when fetching:</simpara>\r
199 <screen>$ git fetch mybundle master:localRef</screen>\r
200 <simpara>You can also see what references it offers:</simpara>\r
201 <screen>$ git ls-remote mybundle</screen>\r
202 </simplesect>\r
203 <simplesect id="_git">\r
204 <title>GIT</title>\r
205 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
206 </simplesect>\r
207 </article>\r