Autogenerated HTML docs for v1.7.1-78-g212f0
[git/jnareb-git.git] / git-clone.html
blob895612ea2f49f53bef8733a1cc39254b704fa336
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.2.5" />
7 <style type="text/css">
8 /* Debug borders */
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11 border: 1px solid red;
15 body {
16 margin: 1em 5% 1em 5%;
19 a {
20 color: blue;
21 text-decoration: underline;
23 a:visited {
24 color: fuchsia;
27 em {
28 font-style: italic;
31 strong {
32 font-weight: bold;
35 tt {
36 color: navy;
39 h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
47 h1, h2, h3 {
48 border-bottom: 2px solid silver;
50 h2 {
51 padding-top: 0.5em;
53 h3 {
54 float: left;
56 h3 + * {
57 clear: left;
60 div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
65 hr {
66 border: 1px solid silver;
69 p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
74 pre {
75 padding: 0;
76 margin: 0;
79 span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
83 font-size: 1.1em;
85 span#email {
87 span#revision {
88 font-family: sans-serif;
91 div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
98 div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
102 div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
107 div#preamble,
108 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110 div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
115 div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
120 div.content { /* Block element content. */
121 padding: 0;
124 /* Block element titles. */
125 div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
132 div.title + * {
133 margin-top: 0;
136 td div.title:first-child {
137 margin-top: 0.0em;
139 div.content div.title:first-child {
140 margin-top: 0.0em;
142 div.content + div.title {
143 margin-top: 0.0em;
146 div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
152 div.listingblock {
153 margin-right: 0%;
155 div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
161 div.quoteblock > div.content {
162 padding-left: 2.0em;
165 div.attribution {
166 text-align: right;
168 div.verseblock + div.attribution {
169 text-align: left;
172 div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
180 div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
185 div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
190 div.verseblock div.content {
191 white-space: pre;
194 div.imageblock div.content { padding-left: 0; }
195 div.imageblock img { border: 1px solid silver; }
196 span.image img { border-style: none; }
198 dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
202 dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
207 dd > *:first-child {
208 margin-top: 0;
211 ul, ol {
212 list-style-position: outside;
214 div.olist2 ol {
215 list-style-type: lower-alpha;
218 div.tableblock > table {
219 border: 3px solid #527bbd;
221 thead {
222 font-family: sans-serif;
223 font-weight: bold;
225 tfoot {
226 font-weight: bold;
229 div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
233 div.hlist td {
234 padding-bottom: 5px;
236 td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
241 td.hlist2 {
242 vertical-align: top;
245 @media print {
246 div#footer-badges { display: none; }
249 div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
258 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
262 div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
266 div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
270 div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
274 include1::./stylesheets/xhtml11-manpage.css[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
282 div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
289 div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
295 div.quoteblock-content {
296 padding-left: 2.0em;
299 div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc a:visited { color: blue; }
306 </style>
307 <title>git-clone(1)</title>
308 </head>
309 <body>
310 <div id="header">
311 <h1>
312 git-clone(1) Manual Page
313 </h1>
314 <h2>NAME</h2>
315 <div class="sectionbody">
316 <p>git-clone -
317 Clone a repository into a new directory
318 </p>
319 </div>
320 </div>
321 <h2>SYNOPSIS</h2>
322 <div class="sectionbody">
323 <div class="verseblock">
324 <div class="content"><em>git clone</em> [--template=&lt;template_directory&gt;]
325 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
326 [-o &lt;name&gt;] [-b &lt;name&gt;] [-u &lt;upload-pack&gt;] [--reference &lt;repository&gt;]
327 [--depth &lt;depth&gt;] [--recursive] [--] &lt;repository&gt; [&lt;directory&gt;]</div></div>
328 </div>
329 <h2 id="_description">DESCRIPTION</h2>
330 <div class="sectionbody">
331 <div class="para"><p>Clones a repository into a newly created directory, creates
332 remote-tracking branches for each branch in the cloned repository
333 (visible using <tt>git branch -r</tt>), and creates and checks out an
334 initial branch that is forked from the cloned repository's
335 currently active branch.</p></div>
336 <div class="para"><p>After the clone, a plain <tt>git fetch</tt> without arguments will update
337 all the remote-tracking branches, and a <tt>git pull</tt> without
338 arguments will in addition merge the remote master branch into the
339 current master branch, if any.</p></div>
340 <div class="para"><p>This default configuration is achieved by creating references to
341 the remote branch heads under <tt>refs/remotes/origin</tt> and
342 by initializing <tt>remote.origin.url</tt> and <tt>remote.origin.fetch</tt>
343 configuration variables.</p></div>
344 </div>
345 <h2 id="_options">OPTIONS</h2>
346 <div class="sectionbody">
347 <div class="vlist"><dl>
348 <dt>
349 --local
350 </dt>
351 <dt>
353 </dt>
354 <dd>
356 When the repository to clone from is on a local machine,
357 this flag bypasses the normal "git aware" transport
358 mechanism and clones the repository by making a copy of
359 HEAD and everything under objects and refs directories.
360 The files under <tt>.git/objects/</tt> directory are hardlinked
361 to save space when possible. This is now the default when
362 the source repository is specified with <tt>/path/to/repo</tt>
363 syntax, so it essentially is a no-op option. To force
364 copying instead of hardlinking (which may be desirable
365 if you are trying to make a back-up of your repository),
366 but still avoid the usual "git aware" transport
367 mechanism, <tt>--no-hardlinks</tt> can be used.
368 </p>
369 </dd>
370 <dt>
371 --no-hardlinks
372 </dt>
373 <dd>
375 Optimize the cloning process from a repository on a
376 local filesystem by copying files under <tt>.git/objects</tt>
377 directory.
378 </p>
379 </dd>
380 <dt>
381 --shared
382 </dt>
383 <dt>
385 </dt>
386 <dd>
388 When the repository to clone is on the local machine,
389 instead of using hard links, automatically setup
390 <tt>.git/objects/info/alternates</tt> to share the objects
391 with the source repository. The resulting repository
392 starts out without any object of its own.
393 </p>
394 <div class="para"><p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use
395 it unless you understand what it does. If you clone your
396 repository using this option and then delete branches (or use any
397 other git command that makes any existing commit unreferenced) in the
398 source repository, some objects may become unreferenced (or dangling).
399 These objects may be removed by normal git operations (such as <tt>git commit</tt>)
400 which automatically call <tt>git gc --auto</tt>. (See <a href="git-gc.html">git-gc(1)</a>.)
401 If these objects are removed and were referenced by the cloned repository,
402 then the cloned repository will become corrupt.</p></div>
403 <div class="para"><p>Note that running <tt>git repack</tt> without the <tt>-l</tt> option in a repository
404 cloned with <tt>-s</tt> will copy objects from the source repository into a pack
405 in the cloned repository, removing the disk space savings of <tt>clone -s</tt>.
406 It is safe, however, to run <tt>git gc</tt>, which uses the <tt>-l</tt> option by
407 default.</p></div>
408 <div class="para"><p>If you want to break the dependency of a repository cloned with <tt>-s</tt> on
409 its source repository, you can simply run <tt>git repack -a</tt> to copy all
410 objects from the source repository into a pack in the cloned repository.</p></div>
411 </dd>
412 <dt>
413 --reference &lt;repository&gt;
414 </dt>
415 <dd>
417 If the reference repository is on the local machine,
418 automatically setup <tt>.git/objects/info/alternates</tt> to
419 obtain objects from the reference repository. Using
420 an already existing repository as an alternate will
421 require fewer objects to be copied from the repository
422 being cloned, reducing network and local storage costs.
423 </p>
424 <div class="para"><p><strong>NOTE</strong>: see the NOTE for the <tt>--shared</tt> option.</p></div>
425 </dd>
426 <dt>
427 --quiet
428 </dt>
429 <dt>
431 </dt>
432 <dd>
434 Operate quietly. Progress is not reported to the standard
435 error stream. This flag is also passed to the `rsync'
436 command when given.
437 </p>
438 </dd>
439 <dt>
440 --verbose
441 </dt>
442 <dt>
444 </dt>
445 <dd>
447 Run verbosely. Does not affect the reporting of progress status
448 to the standard error stream.
449 </p>
450 </dd>
451 <dt>
452 --progress
453 </dt>
454 <dd>
456 Progress status is reported on the standard error stream
457 by default when it is attached to a terminal, unless -q
458 is specified. This flag forces progress status even if the
459 standard error stream is not directed to a terminal.
460 </p>
461 </dd>
462 <dt>
463 --no-checkout
464 </dt>
465 <dt>
467 </dt>
468 <dd>
470 No checkout of HEAD is performed after the clone is complete.
471 </p>
472 </dd>
473 <dt>
474 --bare
475 </dt>
476 <dd>
478 Make a <em>bare</em> GIT repository. That is, instead of
479 creating <tt>&lt;directory&gt;</tt> and placing the administrative
480 files in <tt>&lt;directory&gt;/.git</tt>, make the <tt>&lt;directory&gt;</tt>
481 itself the <tt>$GIT_DIR</tt>. This obviously implies the <tt>-n</tt>
482 because there is nowhere to check out the working tree.
483 Also the branch heads at the remote are copied directly
484 to corresponding local branch heads, without mapping
485 them to <tt>refs/remotes/origin/</tt>. When this option is
486 used, neither remote-tracking branches nor the related
487 configuration variables are created.
488 </p>
489 </dd>
490 <dt>
491 --mirror
492 </dt>
493 <dd>
495 Set up a mirror of the remote repository. This implies <tt>--bare</tt>.
496 </p>
497 </dd>
498 <dt>
499 --origin &lt;name&gt;
500 </dt>
501 <dt>
502 -o &lt;name&gt;
503 </dt>
504 <dd>
506 Instead of using the remote name <tt>origin</tt> to keep track
507 of the upstream repository, use <tt>&lt;name&gt;</tt>.
508 </p>
509 </dd>
510 <dt>
511 --branch &lt;name&gt;
512 </dt>
513 <dt>
514 -b &lt;name&gt;
515 </dt>
516 <dd>
518 Instead of pointing the newly created HEAD to the branch pointed
519 to by the cloned repository's HEAD, point to <tt>&lt;name&gt;</tt> branch
520 instead. In a non-bare repository, this is the branch that will
521 be checked out.
522 </p>
523 </dd>
524 <dt>
525 --upload-pack &lt;upload-pack&gt;
526 </dt>
527 <dt>
528 -u &lt;upload-pack&gt;
529 </dt>
530 <dd>
532 When given, and the repository to clone from is accessed
533 via ssh, this specifies a non-default path for the command
534 run on the other end.
535 </p>
536 </dd>
537 <dt>
538 --template=&lt;template_directory&gt;
539 </dt>
540 <dd>
542 Specify the directory from which templates will be used;
543 (See the "TEMPLATE DIRECTORY" section of <a href="git-init.html">git-init(1)</a>.)
544 </p>
545 </dd>
546 <dt>
547 --depth &lt;depth&gt;
548 </dt>
549 <dd>
551 Create a <em>shallow</em> clone with a history truncated to the
552 specified number of revisions. A shallow repository has a
553 number of limitations (you cannot clone or fetch from
554 it, nor push from nor into it), but is adequate if you
555 are only interested in the recent history of a large project
556 with a long history, and would want to send in fixes
557 as patches.
558 </p>
559 </dd>
560 <dt>
561 --recursive
562 </dt>
563 <dd>
565 After the clone is created, initialize all submodules within,
566 using their default settings. This is equivalent to running
567 <tt>git submodule update --init --recursive</tt> immediately after
568 the clone is finished. This option is ignored if the cloned
569 repository does not have a worktree/checkout (i.e. if any of
570 <tt>--no-checkout</tt>/<tt>-n</tt>, <tt>--bare</tt>, or <tt>--mirror</tt> is given)
571 </p>
572 </dd>
573 <dt>
574 &lt;repository&gt;
575 </dt>
576 <dd>
578 The (possibly remote) repository to clone from. See the
579 <a href="#URLS">URLS</a> section below for more information on specifying
580 repositories.
581 </p>
582 </dd>
583 <dt>
584 &lt;directory&gt;
585 </dt>
586 <dd>
588 The name of a new directory to clone into. The "humanish"
589 part of the source repository is used if no directory is
590 explicitly given (<tt>repo</tt> for <tt>/path/to/repo.git</tt> and <tt>foo</tt>
591 for <tt>host.xz:foo/.git</tt>). Cloning into an existing directory
592 is only allowed if the directory is empty.
593 </p>
594 </dd>
595 </dl></div>
596 </div>
597 <h2 id="_git_urls_a_id_urls_a">GIT URLS<a id="URLS"></a></h2>
598 <div class="sectionbody">
599 <div class="para"><p>In general, URLs contain information about the transport protocol, the
600 address of the remote server, and the path to the repository.
601 Depending on the transport protocol, some of this information may be
602 absent.</p></div>
603 <div class="para"><p>Git natively supports ssh, git, http, https, ftp, ftps, and rsync
604 protocols. The following syntaxes may be used with them:</p></div>
605 <div class="ilist"><ul>
606 <li>
608 ssh://&#91;user@&#93;host.xz&#91;:port&#93;/path/to/repo.git/
609 </p>
610 </li>
611 <li>
613 git://host.xz&#91;:port&#93;/path/to/repo.git/
614 </p>
615 </li>
616 <li>
618 http&#91;s&#93;://host.xz&#91;:port&#93;/path/to/repo.git/
619 </p>
620 </li>
621 <li>
623 ftp&#91;s&#93;://host.xz&#91;:port&#93;/path/to/repo.git/
624 </p>
625 </li>
626 <li>
628 rsync://host.xz/path/to/repo.git/
629 </p>
630 </li>
631 </ul></div>
632 <div class="para"><p>An alternative scp-like syntax may also be used with the ssh protocol:</p></div>
633 <div class="ilist"><ul>
634 <li>
636 &#91;user@&#93;host.xz:path/to/repo.git/
637 </p>
638 </li>
639 </ul></div>
640 <div class="para"><p>The ssh and git protocols additionally support ~username expansion:</p></div>
641 <div class="ilist"><ul>
642 <li>
644 ssh://&#91;user@&#93;host.xz&#91;:port&#93;/~&#91;user&#93;/path/to/repo.git/
645 </p>
646 </li>
647 <li>
649 git://host.xz&#91;:port&#93;/~&#91;user&#93;/path/to/repo.git/
650 </p>
651 </li>
652 <li>
654 &#91;user@&#93;host.xz:/~&#91;user&#93;/path/to/repo.git/
655 </p>
656 </li>
657 </ul></div>
658 <div class="para"><p>For local respositories, also supported by git natively, the following
659 syntaxes may be used:</p></div>
660 <div class="ilist"><ul>
661 <li>
663 /path/to/repo.git/
664 </p>
665 </li>
666 <li>
668 file:///path/to/repo.git/
669 </p>
670 </li>
671 </ul></div>
672 <div class="para"><p>These two syntaxes are mostly equivalent, except the former implies
673 --local option.</p></div>
674 <div class="para"><p>When git doesn't know how to handle a certain transport protocol, it
675 attempts to use the <em>remote-&lt;transport&gt;</em> remote helper, if one
676 exists. To explicitly request a remote helper, the following syntax
677 may be used:</p></div>
678 <div class="ilist"><ul>
679 <li>
681 &lt;transport&gt;::&lt;address&gt;
682 </p>
683 </li>
684 </ul></div>
685 <div class="para"><p>where &lt;address&gt; may be a path, a server and path, or an arbitrary
686 URL-like string recognized by the specific remote helper being
687 invoked. See <a href="git-remote-helpers.html">git-remote-helpers(1)</a> for details.</p></div>
688 <div class="para"><p>If there are a large number of similarly-named remote repositories and
689 you want to use a different format for them (such that the URLs you
690 use will be rewritten into URLs that work), you can create a
691 configuration section of the form:</p></div>
692 <div class="listingblock">
693 <div class="content">
694 <pre><tt> [url "&lt;actual url base&gt;"]
695 insteadOf = &lt;other url base&gt;</tt></pre>
696 </div></div>
697 <div class="para"><p>For example, with this:</p></div>
698 <div class="listingblock">
699 <div class="content">
700 <pre><tt> [url "git://git.host.xz/"]
701 insteadOf = host.xz:/path/to/
702 insteadOf = work:</tt></pre>
703 </div></div>
704 <div class="para"><p>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
705 rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</p></div>
706 <div class="para"><p>If you want to rewrite URLs for push only, you can create a
707 configuration section of the form:</p></div>
708 <div class="listingblock">
709 <div class="content">
710 <pre><tt> [url "&lt;actual url base&gt;"]
711 pushInsteadOf = &lt;other url base&gt;</tt></pre>
712 </div></div>
713 <div class="para"><p>For example, with this:</p></div>
714 <div class="listingblock">
715 <div class="content">
716 <pre><tt> [url "ssh://example.org/"]
717 pushInsteadOf = git://example.org/</tt></pre>
718 </div></div>
719 <div class="para"><p>a URL like "git://example.org/path/to/repo.git" will be rewritten to
720 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
721 use the original URL.</p></div>
722 </div>
723 <h2 id="_examples">Examples</h2>
724 <div class="sectionbody">
725 <div class="ilist"><ul>
726 <li>
728 Clone from upstream:
729 </p>
730 <div class="listingblock">
731 <div class="content">
732 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
733 $ cd my2.6
734 $ make</tt></pre>
735 </div></div>
736 </li>
737 <li>
739 Make a local clone that borrows from the current directory, without checking things out:
740 </p>
741 <div class="listingblock">
742 <div class="content">
743 <pre><tt>$ git clone -l -s -n . ../copy
744 $ cd ../copy
745 $ git show-branch</tt></pre>
746 </div></div>
747 </li>
748 <li>
750 Clone from upstream while borrowing from an existing local directory:
751 </p>
752 <div class="listingblock">
753 <div class="content">
754 <pre><tt>$ git clone --reference my2.6 \
755 git://git.kernel.org/pub/scm/.../linux-2.7 \
756 my2.7
757 $ cd my2.7</tt></pre>
758 </div></div>
759 </li>
760 <li>
762 Create a bare repository to publish your changes to the public:
763 </p>
764 <div class="listingblock">
765 <div class="content">
766 <pre><tt>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git</tt></pre>
767 </div></div>
768 </li>
769 <li>
771 Create a repository on the kernel.org machine that borrows from Linus:
772 </p>
773 <div class="listingblock">
774 <div class="content">
775 <pre><tt>$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
776 /pub/scm/.../me/subsys-2.6.git</tt></pre>
777 </div></div>
778 </li>
779 </ul></div>
780 </div>
781 <h2 id="_author">Author</h2>
782 <div class="sectionbody">
783 <div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
784 </div>
785 <h2 id="_documentation">Documentation</h2>
786 <div class="sectionbody">
787 <div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
788 </div>
789 <h2 id="_git">GIT</h2>
790 <div class="sectionbody">
791 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
792 </div>
793 <div id="footer">
794 <div id="footer-text">
795 Last updated 2010-04-24 02:55:49 UTC
796 </div>
797 </div>
798 </body>
799 </html>