Autogenerated HTML docs for v1.6.3.2-214-gf4f78
[git/jnareb-git.git] / git-clone.html
blob90d487a82bcbe46e22c225a923aba682c694a9c3
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;] [-u &lt;upload-pack&gt;] [--reference &lt;repository&gt;]
327 [--depth &lt;depth&gt;] [--] &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 initial
334 branch equal to the cloned repository's currently active branch.</p></div>
335 <div class="para"><p>After the clone, a plain <tt>git fetch</tt> without arguments will update
336 all the remote-tracking branches, and a <tt>git pull</tt> without
337 arguments will in addition merge the remote master branch into the
338 current master branch, if any.</p></div>
339 <div class="para"><p>This default configuration is achieved by creating references to
340 the remote branch heads under <tt>$GIT_DIR/refs/remotes/origin</tt> and
341 by initializing <tt>remote.origin.url</tt> and <tt>remote.origin.fetch</tt>
342 configuration variables.</p></div>
343 </div>
344 <h2 id="_options">OPTIONS</h2>
345 <div class="sectionbody">
346 <div class="vlist"><dl>
347 <dt>
348 --local
349 </dt>
350 <dt>
352 </dt>
353 <dd>
355 When the repository to clone from is on a local machine,
356 this flag bypasses normal "git aware" transport
357 mechanism and clones the repository by making a copy of
358 HEAD and everything under objects and refs directories.
359 The files under <tt>.git/objects/</tt> directory are hardlinked
360 to save space when possible. This is now the default when
361 the source repository is specified with <tt>/path/to/repo</tt>
362 syntax, so it essentially is a no-op option. To force
363 copying instead of hardlinking (which may be desirable
364 if you are trying to make a back-up of your repository),
365 but still avoid the usual "git aware" transport
366 mechanism, <tt>--no-hardlinks</tt> can be used.
367 </p>
368 </dd>
369 <dt>
370 --no-hardlinks
371 </dt>
372 <dd>
374 Optimize the cloning process from a repository on a
375 local filesystem by copying files under <tt>.git/objects</tt>
376 directory.
377 </p>
378 </dd>
379 <dt>
380 --shared
381 </dt>
382 <dt>
384 </dt>
385 <dd>
387 When the repository to clone is on the local machine,
388 instead of using hard links, automatically setup
389 .git/objects/info/alternates to share the objects
390 with the source repository. The resulting repository
391 starts out without any object of its own.
392 </p>
393 <div class="para"><p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use
394 it unless you understand what it does. If you clone your
395 repository using this option and then delete branches (or use any
396 other git command that makes any existing commit unreferenced) in the
397 source repository, some objects may become unreferenced (or dangling).
398 These objects may be removed by normal git operations (such as <em>git-commit</em>)
399 which automatically call <tt>git gc --auto</tt>. (See <a href="git-gc.html">git-gc(1)</a>.)
400 If these objects are removed and were referenced by the cloned repository,
401 then the cloned repository will become corrupt.</p></div>
402 </dd>
403 <dt>
404 --reference &lt;repository&gt;
405 </dt>
406 <dd>
408 If the reference repository is on the local machine
409 automatically setup .git/objects/info/alternates to
410 obtain objects from the reference repository. Using
411 an already existing repository as an alternate will
412 require fewer objects to be copied from the repository
413 being cloned, reducing network and local storage costs.
414 </p>
415 <div class="para"><p><strong>NOTE</strong>: see NOTE to --shared option.</p></div>
416 </dd>
417 <dt>
418 --quiet
419 </dt>
420 <dt>
422 </dt>
423 <dd>
425 Operate quietly. This flag is also passed to the `rsync'
426 command when given.
427 </p>
428 </dd>
429 <dt>
430 --verbose
431 </dt>
432 <dt>
434 </dt>
435 <dd>
437 Display the progressbar, even in case the standard output is not
438 a terminal.
439 </p>
440 </dd>
441 <dt>
442 --no-checkout
443 </dt>
444 <dt>
446 </dt>
447 <dd>
449 No checkout of HEAD is performed after the clone is complete.
450 </p>
451 </dd>
452 <dt>
453 --bare
454 </dt>
455 <dd>
457 Make a <em>bare</em> GIT repository. That is, instead of
458 creating <tt>&lt;directory&gt;</tt> and placing the administrative
459 files in <tt>&lt;directory&gt;/.git</tt>, make the <tt>&lt;directory&gt;</tt>
460 itself the <tt>$GIT_DIR</tt>. This obviously implies the <tt>-n</tt>
461 because there is nowhere to check out the working tree.
462 Also the branch heads at the remote are copied directly
463 to corresponding local branch heads, without mapping
464 them to <tt>refs/remotes/origin/</tt>. When this option is
465 used, neither remote-tracking branches nor the related
466 configuration variables are created.
467 </p>
468 </dd>
469 <dt>
470 --mirror
471 </dt>
472 <dd>
474 Set up a mirror of the remote repository. This implies --bare.
475 </p>
476 </dd>
477 <dt>
478 --origin &lt;name&gt;
479 </dt>
480 <dt>
481 -o &lt;name&gt;
482 </dt>
483 <dd>
485 Instead of using the remote name <em>origin</em> to keep track
486 of the upstream repository, use &lt;name&gt;.
487 </p>
488 </dd>
489 <dt>
490 --upload-pack &lt;upload-pack&gt;
491 </dt>
492 <dt>
493 -u &lt;upload-pack&gt;
494 </dt>
495 <dd>
497 When given, and the repository to clone from is accessed
498 via ssh, this specifies a non-default path for the command
499 run on the other end.
500 </p>
501 </dd>
502 <dt>
503 --template=&lt;template_directory&gt;
504 </dt>
505 <dd>
507 Specify the directory from which templates will be used;
508 if unset the templates are taken from the installation
509 defined default, typically <tt>/usr/share/git-core/templates</tt>.
510 </p>
511 </dd>
512 <dt>
513 --depth &lt;depth&gt;
514 </dt>
515 <dd>
517 Create a <em>shallow</em> clone with a history truncated to the
518 specified number of revisions. A shallow repository has a
519 number of limitations (you cannot clone or fetch from
520 it, nor push from nor into it), but is adequate if you
521 are only interested in the recent history of a large project
522 with a long history, and would want to send in fixes
523 as patches.
524 </p>
525 </dd>
526 <dt>
527 &lt;repository&gt;
528 </dt>
529 <dd>
531 The (possibly remote) repository to clone from. See the
532 <a href="#URLS">URLS</a> section below for more information on specifying
533 repositories.
534 </p>
535 </dd>
536 <dt>
537 &lt;directory&gt;
538 </dt>
539 <dd>
541 The name of a new directory to clone into. The "humanish"
542 part of the source repository is used if no directory is
543 explicitly given ("repo" for "/path/to/repo.git" and "foo"
544 for "host.xz:foo/.git"). Cloning into an existing directory
545 is only allowed if the directory is empty.
546 </p>
547 </dd>
548 </dl></div>
549 </div>
550 <h2 id="_git_urls_a_id_urls_a">GIT URLS<a id="URLS"></a></h2>
551 <div class="sectionbody">
552 <div class="para"><p>One of the following notations can be used
553 to name the remote repository:</p></div>
554 <div class="exampleblock">
555 <div class="exampleblock-content">
556 <div class="ilist"><ul>
557 <li>
559 rsync://host.xz/path/to/repo.git/
560 </p>
561 </li>
562 <li>
564 http://host.xz&#91;:port&#93;/path/to/repo.git/
565 </p>
566 </li>
567 <li>
569 https://host.xz&#91;:port&#93;/path/to/repo.git/
570 </p>
571 </li>
572 <li>
574 git://host.xz&#91;:port&#93;/path/to/repo.git/
575 </p>
576 </li>
577 <li>
579 git://host.xz&#91;:port&#93;/~user/path/to/repo.git/
580 </p>
581 </li>
582 <li>
584 ssh://&#91;user@&#93;host.xz&#91;:port&#93;/path/to/repo.git/
585 </p>
586 </li>
587 <li>
589 ssh://&#91;user@&#93;host.xz/path/to/repo.git/
590 </p>
591 </li>
592 <li>
594 ssh://&#91;user@&#93;host.xz/~user/path/to/repo.git/
595 </p>
596 </li>
597 <li>
599 ssh://&#91;user@&#93;host.xz/~/path/to/repo.git
600 </p>
601 </li>
602 </ul></div>
603 </div></div>
604 <div class="para"><p>SSH is the default transport protocol over the network. You can
605 optionally specify which user to log-in as, and an alternate,
606 scp-like syntax is also supported. Both syntaxes support
607 username expansion, as does the native git protocol, but
608 only the former supports port specification. The following
609 three are identical to the last three above, respectively:</p></div>
610 <div class="exampleblock">
611 <div class="exampleblock-content">
612 <div class="ilist"><ul>
613 <li>
615 &#91;user@&#93;host.xz:/path/to/repo.git/
616 </p>
617 </li>
618 <li>
620 &#91;user@&#93;host.xz:~user/path/to/repo.git/
621 </p>
622 </li>
623 <li>
625 &#91;user@&#93;host.xz:path/to/repo.git
626 </p>
627 </li>
628 </ul></div>
629 </div></div>
630 <div class="para"><p>To sync with a local directory, you can use:</p></div>
631 <div class="exampleblock">
632 <div class="exampleblock-content">
633 <div class="ilist"><ul>
634 <li>
636 /path/to/repo.git/
637 </p>
638 </li>
639 <li>
641 file:///path/to/repo.git/
642 </p>
643 </li>
644 </ul></div>
645 </div></div>
646 <div class="para"><p>They are equivalent, except the former implies --local option.</p></div>
647 <div class="para"><p>If there are a large number of similarly-named remote repositories and
648 you want to use a different format for them (such that the URLs you
649 use will be rewritten into URLs that work), you can create a
650 configuration section of the form:</p></div>
651 <div class="listingblock">
652 <div class="content">
653 <pre><tt> [url "&lt;actual url base&gt;"]
654 insteadOf = &lt;other url base&gt;</tt></pre>
655 </div></div>
656 <div class="para"><p>For example, with this:</p></div>
657 <div class="listingblock">
658 <div class="content">
659 <pre><tt> [url "git://git.host.xz/"]
660 insteadOf = host.xz:/path/to/
661 insteadOf = work:</tt></pre>
662 </div></div>
663 <div class="para"><p>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
664 rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</p></div>
665 </div>
666 <h2 id="_examples">Examples</h2>
667 <div class="sectionbody">
668 <div class="vlist"><dl>
669 <dt>
670 Clone from upstream
671 </dt>
672 <dd>
673 <div class="listingblock">
674 <div class="content">
675 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
676 $ cd my2.6
677 $ make</tt></pre>
678 </div></div>
679 </dd>
680 <dt>
681 Make a local clone that borrows from the current directory, without checking things out
682 </dt>
683 <dd>
684 <div class="listingblock">
685 <div class="content">
686 <pre><tt>$ git clone -l -s -n . ../copy
687 $ cd ../copy
688 $ git show-branch</tt></pre>
689 </div></div>
690 </dd>
691 <dt>
692 Clone from upstream while borrowing from an existing local directory
693 </dt>
694 <dd>
695 <div class="listingblock">
696 <div class="content">
697 <pre><tt>$ git clone --reference my2.6 \
698 git://git.kernel.org/pub/scm/.../linux-2.7 \
699 my2.7
700 $ cd my2.7</tt></pre>
701 </div></div>
702 </dd>
703 <dt>
704 Create a bare repository to publish your changes to the public
705 </dt>
706 <dd>
707 <div class="listingblock">
708 <div class="content">
709 <pre><tt>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git</tt></pre>
710 </div></div>
711 </dd>
712 <dt>
713 Create a repository on the kernel.org machine that borrows from Linus
714 </dt>
715 <dd>
716 <div class="listingblock">
717 <div class="content">
718 <pre><tt>$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
719 /pub/scm/.../me/subsys-2.6.git</tt></pre>
720 </div></div>
721 </dd>
722 </dl></div>
723 </div>
724 <h2 id="_author">Author</h2>
725 <div class="sectionbody">
726 <div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
727 </div>
728 <h2 id="_documentation">Documentation</h2>
729 <div class="sectionbody">
730 <div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
731 </div>
732 <h2 id="_git">GIT</h2>
733 <div class="sectionbody">
734 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
735 </div>
736 <div id="footer">
737 <div id="footer-text">
738 Last updated 2009-05-10 06:47:56 UTC
739 </div>
740 </div>
741 </body>
742 </html>