Updated git_doc to git 1.8
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-clone.xml
blob9de1dcbe5c0dd4ede2a9d51bee0edd809f891ab4
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <sect2 lang="en" id="git-clone(1)">\r
5     <title>git-clone(1)</title>\r
6 <indexterm>\r
7 <primary>git-clone(1)</primary>\r
8 </indexterm>\r
9 <simplesect id="git-clone(1)__name">\r
10 <title>NAME</title>\r
11 <simpara>git-clone - Clone a repository into a new directory</simpara>\r
12 </simplesect>\r
13 <simplesect id="git-clone(1)__synopsis">\r
14 <title>SYNOPSIS</title>\r
15 <blockquote>\r
16 <literallayout><emphasis>git clone</emphasis> [--template=&lt;template_directory&gt;]\r
17           [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]\r
18           [-o &lt;name&gt;] [-b &lt;name&gt;] [-u &lt;upload-pack&gt;] [--reference &lt;repository&gt;]\r
19           [--separate-git-dir &lt;git dir&gt;]\r
20           [--depth &lt;depth&gt;] [--[no-]single-branch]\r
21           [--recursive|--recurse-submodules] [--] &lt;repository&gt;\r
22           [&lt;directory&gt;]</literallayout>\r
23 </blockquote>\r
24 </simplesect>\r
25 <simplesect id="git-clone(1)__description">\r
26 <title>DESCRIPTION</title>\r
27 <simpara>Clones a repository into a newly created directory, creates\r
28 remote-tracking branches for each branch in the cloned repository\r
29 (visible using <emphasis>git branch -r</emphasis>), and creates and checks out an\r
30 initial branch that is forked from the cloned repository's\r
31 currently active branch.</simpara>\r
32 <simpara>After the clone, a plain <emphasis>git fetch</emphasis> without arguments will update\r
33 all the remote-tracking branches, and a <emphasis>git pull</emphasis> without\r
34 arguments will in addition merge the remote master branch into the\r
35 current master branch, if any (this is untrue when "--single-branch"\r
36 is given; see below).</simpara>\r
37 <simpara>This default configuration is achieved by creating references to\r
38 the remote branch heads under <emphasis>refs/remotes/origin</emphasis> and\r
39 by initializing <emphasis>remote.origin.url</emphasis> and <emphasis>remote.origin.fetch</emphasis>\r
40 configuration variables.</simpara>\r
41 </simplesect>\r
42 <simplesect id="git-clone(1)__options">\r
43 <title>OPTIONS</title>\r
44 <variablelist>\r
45 <varlistentry>\r
46 <term>\r
47 --local\r
48 </term>\r
49 <term>\r
50 -l\r
51 </term>\r
52 <listitem>\r
53 <simpara>\r
54         When the repository to clone from is on a local machine,\r
55         this flag bypasses the normal "git aware" transport\r
56         mechanism and clones the repository by making a copy of\r
57         HEAD and everything under objects and refs directories.\r
58         The files under <emphasis>.git/objects/</emphasis> directory are hardlinked\r
59         to save space when possible.\r
60 </simpara>\r
61 <simpara>If the repository is specified as a local path (e.g., <emphasis>/path/to/repo</emphasis>),\r
62 this is the default, and --local is essentially a no-op.  If the\r
63 repository is specified as a URL, then this flag is ignored (and we\r
64 never use the local optimizations).  Specifying <emphasis>--no-local</emphasis> will\r
65 override the default when <emphasis>/path/to/repo</emphasis> is given, using the regular\r
66 git transport instead.</simpara>\r
67 <simpara>To force copying instead of hardlinking (which may be desirable if you\r
68 are trying to make a back-up of your repository), but still avoid the\r
69 usual "git aware" transport mechanism, <emphasis>--no-hardlinks</emphasis> can be used.</simpara>\r
70 </listitem>\r
71 </varlistentry>\r
72 <varlistentry>\r
73 <term>\r
74 --no-hardlinks\r
75 </term>\r
76 <listitem>\r
77 <simpara>\r
78         Optimize the cloning process from a repository on a\r
79         local filesystem by copying files under <emphasis>.git/objects</emphasis>\r
80         directory.\r
81 </simpara>\r
82 </listitem>\r
83 </varlistentry>\r
84 <varlistentry>\r
85 <term>\r
86 --shared\r
87 </term>\r
88 <term>\r
89 -s\r
90 </term>\r
91 <listitem>\r
92 <simpara>\r
93         When the repository to clone is on the local machine,\r
94         instead of using hard links, automatically setup\r
95         <emphasis>.git/objects/info/alternates</emphasis> to share the objects\r
96         with the source repository.  The resulting repository\r
97         starts out without any object of its own.\r
98 </simpara>\r
99 <simpara><emphasis role="strong">NOTE</emphasis>: this is a possibly dangerous operation; do <emphasis role="strong">not</emphasis> use\r
100 it unless you understand what it does. If you clone your\r
101 repository using this option and then delete branches (or use any\r
102 other git command that makes any existing commit unreferenced) in the\r
103 source repository, some objects may become unreferenced (or dangling).\r
104 These objects may be removed by normal git operations (such as <emphasis>git commit</emphasis>)\r
105 which automatically call <emphasis>git gc --auto</emphasis>. (See <xref linkend="git-gc(1)" />.)\r
106 If these objects are removed and were referenced by the cloned repository,\r
107 then the cloned repository will become corrupt.</simpara>\r
108 <simpara>Note that running <emphasis>git repack</emphasis> without the <emphasis>-l</emphasis> option in a repository\r
109 cloned with <emphasis>-s</emphasis> will copy objects from the source repository into a pack\r
110 in the cloned repository, removing the disk space savings of <emphasis>clone -s</emphasis>.\r
111 It is safe, however, to run <emphasis>git gc</emphasis>, which uses the <emphasis>-l</emphasis> option by\r
112 default.</simpara>\r
113 <simpara>If you want to break the dependency of a repository cloned with <emphasis>-s</emphasis> on\r
114 its source repository, you can simply run <emphasis>git repack -a</emphasis> to copy all\r
115 objects from the source repository into a pack in the cloned repository.</simpara>\r
116 </listitem>\r
117 </varlistentry>\r
118 <varlistentry>\r
119 <term>\r
120 --reference &lt;repository&gt;\r
121 </term>\r
122 <listitem>\r
123 <simpara>\r
124         If the reference repository is on the local machine,\r
125         automatically setup <emphasis>.git/objects/info/alternates</emphasis> to\r
126         obtain objects from the reference repository.  Using\r
127         an already existing repository as an alternate will\r
128         require fewer objects to be copied from the repository\r
129         being cloned, reducing network and local storage costs.\r
130 </simpara>\r
131 <simpara><emphasis role="strong">NOTE</emphasis>: see the NOTE for the <emphasis>--shared</emphasis> option.</simpara>\r
132 </listitem>\r
133 </varlistentry>\r
134 <varlistentry>\r
135 <term>\r
136 --quiet\r
137 </term>\r
138 <term>\r
139 -q\r
140 </term>\r
141 <listitem>\r
142 <simpara>\r
143         Operate quietly.  Progress is not reported to the standard\r
144         error stream. This flag is also passed to the rsync\r
145         command when given.\r
146 </simpara>\r
147 </listitem>\r
148 </varlistentry>\r
149 <varlistentry>\r
150 <term>\r
151 --verbose\r
152 </term>\r
153 <term>\r
154 -v\r
155 </term>\r
156 <listitem>\r
157 <simpara>\r
158         Run verbosely. Does not affect the reporting of progress status\r
159         to the standard error stream.\r
160 </simpara>\r
161 </listitem>\r
162 </varlistentry>\r
163 <varlistentry>\r
164 <term>\r
165 --progress\r
166 </term>\r
167 <listitem>\r
168 <simpara>\r
169         Progress status is reported on the standard error stream\r
170         by default when it is attached to a terminal, unless -q\r
171         is specified. This flag forces progress status even if the\r
172         standard error stream is not directed to a terminal.\r
173 </simpara>\r
174 </listitem>\r
175 </varlistentry>\r
176 <varlistentry>\r
177 <term>\r
178 --no-checkout\r
179 </term>\r
180 <term>\r
181 -n\r
182 </term>\r
183 <listitem>\r
184 <simpara>\r
185         No checkout of HEAD is performed after the clone is complete.\r
186 </simpara>\r
187 </listitem>\r
188 </varlistentry>\r
189 <varlistentry>\r
190 <term>\r
191 --bare\r
192 </term>\r
193 <listitem>\r
194 <simpara>\r
195         Make a <emphasis>bare</emphasis> GIT repository.  That is, instead of\r
196         creating <emphasis>&lt;directory&gt;</emphasis> and placing the administrative\r
197         files in <emphasis>&lt;directory&gt;/.git</emphasis>, make the <emphasis>&lt;directory&gt;</emphasis>\r
198         itself the <emphasis>$GIT_DIR</emphasis>. This obviously implies the <emphasis>-n</emphasis>\r
199         because there is nowhere to check out the working tree.\r
200         Also the branch heads at the remote are copied directly\r
201         to corresponding local branch heads, without mapping\r
202         them to <emphasis>refs/remotes/origin/</emphasis>.  When this option is\r
203         used, neither remote-tracking branches nor the related\r
204         configuration variables are created.\r
205 </simpara>\r
206 </listitem>\r
207 </varlistentry>\r
208 <varlistentry>\r
209 <term>\r
210 --mirror\r
211 </term>\r
212 <listitem>\r
213 <simpara>\r
214         Set up a mirror of the source repository.  This implies <emphasis>--bare</emphasis>.\r
215         Compared to <emphasis>--bare</emphasis>, <emphasis>--mirror</emphasis> not only maps local branches of the\r
216         source to local branches of the target, it maps all refs (including\r
217         remote-tracking branches, notes etc.) and sets up a refspec configuration such\r
218         that all these refs are overwritten by a <emphasis>git remote update</emphasis> in the\r
219         target repository.\r
220 </simpara>\r
221 </listitem>\r
222 </varlistentry>\r
223 <varlistentry>\r
224 <term>\r
225 --origin &lt;name&gt;\r
226 </term>\r
227 <term>\r
228 -o &lt;name&gt;\r
229 </term>\r
230 <listitem>\r
231 <simpara>\r
232         Instead of using the remote name <emphasis>origin</emphasis> to keep track\r
233         of the upstream repository, use <emphasis>&lt;name&gt;</emphasis>.\r
234 </simpara>\r
235 </listitem>\r
236 </varlistentry>\r
237 <varlistentry>\r
238 <term>\r
239 --branch &lt;name&gt;\r
240 </term>\r
241 <term>\r
242 -b &lt;name&gt;\r
243 </term>\r
244 <listitem>\r
245 <simpara>\r
246         Instead of pointing the newly created HEAD to the branch pointed\r
247         to by the cloned repository's HEAD, point to <emphasis>&lt;name&gt;</emphasis> branch\r
248         instead. In a non-bare repository, this is the branch that will\r
249         be checked out.\r
250         <emphasis>--branch</emphasis> can also take tags and detaches the HEAD at that commit\r
251         in the resulting repository.\r
252 </simpara>\r
253 </listitem>\r
254 </varlistentry>\r
255 <varlistentry>\r
256 <term>\r
257 --upload-pack &lt;upload-pack&gt;\r
258 </term>\r
259 <term>\r
260 -u &lt;upload-pack&gt;\r
261 </term>\r
262 <listitem>\r
263 <simpara>\r
264         When given, and the repository to clone from is accessed\r
265         via ssh, this specifies a non-default path for the command\r
266         run on the other end.\r
267 </simpara>\r
268 </listitem>\r
269 </varlistentry>\r
270 <varlistentry>\r
271 <term>\r
272 --template=&lt;template_directory&gt;\r
273 </term>\r
274 <listitem>\r
275 <simpara>\r
276         Specify the directory from which templates will be used;\r
277         (See the "TEMPLATE DIRECTORY" section of <xref linkend="git-init(1)" />.)\r
278 </simpara>\r
279 </listitem>\r
280 </varlistentry>\r
281 <varlistentry>\r
282 <term>\r
283 --config &lt;key&gt;=&lt;value&gt;\r
284 </term>\r
285 <term>\r
286 -c &lt;key&gt;=&lt;value&gt;\r
287 </term>\r
288 <listitem>\r
289 <simpara>\r
290         Set a configuration variable in the newly-created repository;\r
291         this takes effect immediately after the repository is\r
292         initialized, but before the remote history is fetched or any\r
293         files checked out.  The key is in the same format as expected by\r
294         <xref linkend="git-config(1)" /> (e.g., <emphasis>core.eol=true</emphasis>). If multiple\r
295         values are given for the same key, each value will be written to\r
296         the config file. This makes it safe, for example, to add\r
297         additional fetch refspecs to the origin remote.\r
298 </simpara>\r
299 </listitem>\r
300 </varlistentry>\r
301 <varlistentry>\r
302 <term>\r
303 --depth &lt;depth&gt;\r
304 </term>\r
305 <listitem>\r
306 <simpara>\r
307         Create a <emphasis>shallow</emphasis> clone with a history truncated to the\r
308         specified number of revisions.  A shallow repository has a\r
309         number of limitations (you cannot clone or fetch from\r
310         it, nor push from nor into it), but is adequate if you\r
311         are only interested in the recent history of a large project\r
312         with a long history, and would want to send in fixes\r
313         as patches.\r
314 </simpara>\r
315 </listitem>\r
316 </varlistentry>\r
317 <varlistentry>\r
318 <term>\r
319 --single-branch\r
320 </term>\r
321 <listitem>\r
322 <simpara>\r
323         Clone only the history leading to the tip of a single branch,\r
324         either specified by the <emphasis>--branch</emphasis> option or the primary\r
325         branch remote's <emphasis>HEAD</emphasis> points at. When creating a shallow\r
326         clone with the <emphasis>--depth</emphasis> option, this is the default, unless\r
327         <emphasis>--no-single-branch</emphasis> is given to fetch the histories near the\r
328         tips of all branches.\r
329         Further fetches into the resulting repository will only update the\r
330         remote-tracking branch for the branch this option was used for the\r
331         initial cloning.  If the HEAD at the remote did not point at any\r
332         branch when <emphasis>--single-branch</emphasis> clone was made, no remote-tracking\r
333         branch is created.\r
334 </simpara>\r
335 </listitem>\r
336 </varlistentry>\r
337 <varlistentry>\r
338 <term>\r
339 --recursive\r
340 </term>\r
341 <term>\r
342 --recurse-submodules\r
343 </term>\r
344 <listitem>\r
345 <simpara>\r
346         After the clone is created, initialize all submodules within,\r
347         using their default settings. This is equivalent to running\r
348         <emphasis>git submodule update --init --recursive</emphasis> immediately after\r
349         the clone is finished. This option is ignored if the cloned\r
350         repository does not have a worktree/checkout (i.e. if any of\r
351         <emphasis>--no-checkout</emphasis>/<emphasis>-n</emphasis>, <emphasis>--bare</emphasis>, or <emphasis>--mirror</emphasis> is given)\r
352 </simpara>\r
353 </listitem>\r
354 </varlistentry>\r
355 <varlistentry>\r
356 <term>\r
357 --separate-git-dir=&lt;git dir&gt;\r
358 </term>\r
359 <listitem>\r
360 <simpara>\r
361         Instead of placing the cloned repository where it is supposed\r
362         to be, place the cloned repository at the specified directory,\r
363         then make a filesytem-agnostic git symbolic link to there.\r
364         The result is git repository can be separated from working\r
365         tree.\r
366 </simpara>\r
367 </listitem>\r
368 </varlistentry>\r
369 <varlistentry>\r
370 <term>\r
371 &lt;repository&gt;\r
372 </term>\r
373 <listitem>\r
374 <simpara>\r
375         The (possibly remote) repository to clone from.  See the\r
376         <link linkend="git-clone(1)_URLS">URLS</link> section below for more information on specifying\r
377         repositories.\r
378 </simpara>\r
379 </listitem>\r
380 </varlistentry>\r
381 <varlistentry>\r
382 <term>\r
383 &lt;directory&gt;\r
384 </term>\r
385 <listitem>\r
386 <simpara>\r
387         The name of a new directory to clone into.  The "humanish"\r
388         part of the source repository is used if no directory is\r
389         explicitly given (<emphasis>repo</emphasis> for <emphasis>/path/to/repo.git</emphasis> and <emphasis>foo</emphasis>\r
390         for <emphasis>host.xz:foo/.git</emphasis>).  Cloning into an existing directory\r
391         is only allowed if the directory is empty.\r
392 </simpara>\r
393 </listitem>\r
394 </varlistentry>\r
395 </variablelist>\r
396 </simplesect>\r
397 <simplesect id="git-clone(1)__git_urls_anchor_id_git_clone_1__urls_xreflabel_urls">\r
398 <title>GIT URLS<anchor id="git-clone(1)_URLS" xreflabel="[URLS]"/></title>\r
399 <simpara>In general, URLs contain information about the transport protocol, the\r
400 address of the remote server, and the path to the repository.\r
401 Depending on the transport protocol, some of this information may be\r
402 absent.</simpara>\r
403 <simpara>Git supports ssh, git, http, and https protocols (in addition, ftp,\r
404 and ftps can be used for fetching and rsync can be used for fetching\r
405 and pushing, but these are inefficient and deprecated; do not use\r
406 them).</simpara>\r
407 <simpara>The following syntaxes may be used with them:</simpara>\r
408 <itemizedlist>\r
409 <listitem>\r
410 <simpara>\r
411 ssh://&#91;user@&#93;host.xz&#91;:port&#93;/path/to/repo.git/\r
412 </simpara>\r
413 </listitem>\r
414 <listitem>\r
415 <simpara>\r
416 git://host.xz&#91;:port&#93;/path/to/repo.git/\r
417 </simpara>\r
418 </listitem>\r
419 <listitem>\r
420 <simpara>\r
421 http&#91;s&#93;://host.xz&#91;:port&#93;/path/to/repo.git/\r
422 </simpara>\r
423 </listitem>\r
424 <listitem>\r
425 <simpara>\r
426 ftp&#91;s&#93;://host.xz&#91;:port&#93;/path/to/repo.git/\r
427 </simpara>\r
428 </listitem>\r
429 <listitem>\r
430 <simpara>\r
431 rsync://host.xz/path/to/repo.git/\r
432 </simpara>\r
433 </listitem>\r
434 </itemizedlist>\r
435 <simpara>An alternative scp-like syntax may also be used with the ssh protocol:</simpara>\r
436 <itemizedlist>\r
437 <listitem>\r
438 <simpara>\r
439 &#91;user@&#93;host.xz:path/to/repo.git/\r
440 </simpara>\r
441 </listitem>\r
442 </itemizedlist>\r
443 <simpara>The ssh and git protocols additionally support ~username expansion:</simpara>\r
444 <itemizedlist>\r
445 <listitem>\r
446 <simpara>\r
447 ssh://&#91;user@&#93;host.xz&#91;:port&#93;/~&#91;user&#93;/path/to/repo.git/\r
448 </simpara>\r
449 </listitem>\r
450 <listitem>\r
451 <simpara>\r
452 git://host.xz&#91;:port&#93;/~&#91;user&#93;/path/to/repo.git/\r
453 </simpara>\r
454 </listitem>\r
455 <listitem>\r
456 <simpara>\r
457 &#91;user@&#93;host.xz:/~&#91;user&#93;/path/to/repo.git/\r
458 </simpara>\r
459 </listitem>\r
460 </itemizedlist>\r
461 <simpara>For local repositories, also supported by git natively, the following\r
462 syntaxes may be used:</simpara>\r
463 <itemizedlist>\r
464 <listitem>\r
465 <simpara>\r
466 /path/to/repo.git/\r
467 </simpara>\r
468 </listitem>\r
469 <listitem>\r
470 <simpara>\r
471 <ulink url="file:///path/to/repo.git/">file:///path/to/repo.git/</ulink>\r
472 </simpara>\r
473 </listitem>\r
474 </itemizedlist>\r
475 <simpara>These two syntaxes are mostly equivalent, except the former implies\r
476 --local option.</simpara>\r
477 <simpara>When git doesn't know how to handle a certain transport protocol, it\r
478 attempts to use the <emphasis>remote-&lt;transport&gt;</emphasis> remote helper, if one\r
479 exists. To explicitly request a remote helper, the following syntax\r
480 may be used:</simpara>\r
481 <itemizedlist>\r
482 <listitem>\r
483 <simpara>\r
484 &lt;transport&gt;::&lt;address&gt;\r
485 </simpara>\r
486 </listitem>\r
487 </itemizedlist>\r
488 <simpara>where &lt;address&gt; may be a path, a server and path, or an arbitrary\r
489 URL-like string recognized by the specific remote helper being\r
490 invoked. See <xref linkend="git-remote-helpers(1)" /> for details.</simpara>\r
491 <simpara>If there are a large number of similarly-named remote repositories and\r
492 you want to use a different format for them (such that the URLs you\r
493 use will be rewritten into URLs that work), you can create a\r
494 configuration section of the form:</simpara>\r
495 <screen>        [url "&lt;actual url base&gt;"]\r
496                 insteadOf = &lt;other url base&gt;</screen>\r
497 <simpara>For example, with this:</simpara>\r
498 <screen>        [url "git://git.host.xz/"]\r
499                 insteadOf = host.xz:/path/to/\r
500                 insteadOf = work:</screen>\r
501 <simpara>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be\r
502 rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</simpara>\r
503 <simpara>If you want to rewrite URLs for push only, you can create a\r
504 configuration section of the form:</simpara>\r
505 <screen>        [url "&lt;actual url base&gt;"]\r
506                 pushInsteadOf = &lt;other url base&gt;</screen>\r
507 <simpara>For example, with this:</simpara>\r
508 <screen>        [url "ssh://example.org/"]\r
509                 pushInsteadOf = git://example.org/</screen>\r
510 <simpara>a URL like "git://example.org/path/to/repo.git" will be rewritten to\r
511 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still\r
512 use the original URL.</simpara>\r
513 </simplesect>\r
514 <simplesect id="git-clone(1)__examples">\r
515 <title>Examples</title>\r
516 <itemizedlist>\r
517 <listitem>\r
518 <simpara>\r
519 Clone from upstream:\r
520 </simpara>\r
521 <screen>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6\r
522 $ cd my2.6\r
523 $ make</screen>\r
524 </listitem>\r
525 <listitem>\r
526 <simpara>\r
527 Make a local clone that borrows from the current directory, without checking things out:\r
528 </simpara>\r
529 <screen>$ git clone -l -s -n . ../copy\r
530 $ cd ../copy\r
531 $ git show-branch</screen>\r
532 </listitem>\r
533 <listitem>\r
534 <simpara>\r
535 Clone from upstream while borrowing from an existing local directory:\r
536 </simpara>\r
537 <screen>$ git clone --reference my2.6 \\r
538         git://git.kernel.org/pub/scm/.../linux-2.7 \\r
539         my2.7\r
540 $ cd my2.7</screen>\r
541 </listitem>\r
542 <listitem>\r
543 <simpara>\r
544 Create a bare repository to publish your changes to the public:\r
545 </simpara>\r
546 <screen>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git</screen>\r
547 </listitem>\r
548 <listitem>\r
549 <simpara>\r
550 Create a repository on the kernel.org machine that borrows from Linus:\r
551 </simpara>\r
552 <screen>$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \\r
553     /pub/scm/.../me/subsys-2.6.git</screen>\r
554 </listitem>\r
555 </itemizedlist>\r
556 </simplesect>\r
557 <simplesect id="git-clone(1)__git">\r
558 <title>GIT</title>\r
559 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
560 </simplesect>\r
561 </sect2>\r