blob: 958f9776c08ade7cfe2ef86a8adcdf5877dde44d [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!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" />
Junio C Hamano01078922006-03-10 00:31:476<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-clone(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-clone(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-clone -
Junio C Hamano4ec06712007-06-09 20:39:33269 Clone a repository into a new directory
Junio C Hamano1a4e8412005-12-27 08:17:23270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano235a91e2006-01-07 01:13:58275<div class="verseblock">
Junio C Hamanob1d6e882007-08-11 08:30:16276<div class="content"><em>git-clone</em> [--template=&lt;template_directory&gt;]
277 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare]
Junio C Hamanof31d9f52006-05-28 20:58:09278 [-o &lt;name&gt;] [-u &lt;upload-pack&gt;] [--reference &lt;repository&gt;]
Junio C Hamanod814b6d2007-11-04 11:13:49279 [--depth &lt;depth&gt;] [--] &lt;repository&gt; [&lt;directory&gt;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23280</div>
281<h2>DESCRIPTION</h2>
282<div class="sectionbody">
Junio C Hamano5102d9a2006-12-08 07:23:46283<p>Clones a repository into a newly created directory, creates
284remote-tracking branches for each branch in the cloned repository
Junio C Hamano79770b62007-01-07 07:43:58285(visible using <tt>git branch -r</tt>), and creates and checks out an initial
286branch equal to the cloned repository's currently active branch.</p>
Junio C Hamano5102d9a2006-12-08 07:23:46287<p>After the clone, a plain <tt>git fetch</tt> without arguments will update
288all the remote-tracking branches, and a <tt>git pull</tt> without
289arguments will in addition merge the remote master branch into the
Junio C Hamano79770b62007-01-07 07:43:58290current master branch, if any.</p>
Junio C Hamano5102d9a2006-12-08 07:23:46291<p>This default configuration is achieved by creating references to
292the remote branch heads under <tt>$GIT_DIR/refs/remotes/origin</tt> and
293by initializing <tt>remote.origin.url</tt> and <tt>remote.origin.fetch</tt>
294configuration variables.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23295</div>
296<h2>OPTIONS</h2>
297<div class="sectionbody">
298<dl>
299<dt>
300--local
301</dt>
302<dt>
303-l
304</dt>
305<dd>
306<p>
307 When the repository to clone from is on a local machine,
308 this flag bypasses normal "git aware" transport
309 mechanism and clones the repository by making a copy of
310 HEAD and everything under objects and refs directories.
Junio C Hamanob1d6e882007-08-11 08:30:16311 The files under <tt>.git/objects/</tt> directory are hardlinked
312 to save space when possible. This is now the default when
313 the source repository is specified with <tt>/path/to/repo</tt>
314 syntax, so it essentially is a no-op option. To force
315 copying instead of hardlinking (which may be desirable
316 if you are trying to make a back-up of your repository),
317 but still avoid the usual "git aware" transport
318 mechanism, <tt>--no-hardlinks</tt> can be used.
319</p>
320</dd>
321<dt>
322--no-hardlinks
323</dt>
324<dd>
325<p>
326 Optimize the cloning process from a repository on a
327 local filesystem by copying files under <tt>.git/objects</tt>
328 directory.
Junio C Hamano1a4e8412005-12-27 08:17:23329</p>
330</dd>
331<dt>
332--shared
333</dt>
334<dt>
335-s
336</dt>
337<dd>
338<p>
339 When the repository to clone is on the local machine,
340 instead of using hard links, automatically setup
Junio C Hamanof50bfec2006-04-19 09:44:12341 .git/objects/info/alternates to share the objects
Junio C Hamano1a4e8412005-12-27 08:17:23342 with the source repository. The resulting repository
343 starts out without any object of its own.
344</p>
Junio C Hamanoefe3c632008-02-14 00:51:31345<p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use
346it unless you understand what it does. If you clone your
347repository using this option, then delete branches in the
348source repository and then run <a href="git-gc.html">git-gc(1)</a> using the
349<em>--prune</em> option in the source repository, it may remove
350objects which are referenced by the cloned repository.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23351</dd>
352<dt>
Junio C Hamanof50bfec2006-04-19 09:44:12353--reference &lt;repository&gt;
354</dt>
355<dd>
356<p>
357 If the reference repository is on the local machine
358 automatically setup .git/objects/info/alternates to
359 obtain objects from the reference repository. Using
360 an already existing repository as an alternate will
Junio C Hamano250f03e2007-09-10 01:33:28361 require fewer objects to be copied from the repository
Junio C Hamanof50bfec2006-04-19 09:44:12362 being cloned, reducing network and local storage costs.
363</p>
364</dd>
365<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23366--quiet
367</dt>
368<dt>
369-q
370</dt>
371<dd>
372<p>
373 Operate quietly. This flag is passed to "rsync" and
Junio C Hamano97f518c2006-06-22 19:49:35374 "git-fetch-pack" commands when given.
Junio C Hamano1a4e8412005-12-27 08:17:23375</p>
376</dd>
377<dt>
Junio C Hamano1e6e0062007-07-13 05:33:25378--no-checkout
379</dt>
380<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23381-n
382</dt>
383<dd>
384<p>
385 No checkout of HEAD is performed after the clone is complete.
386</p>
387</dd>
388<dt>
Junio C Hamanoe663a7a2006-01-25 12:37:28389--bare
Junio C Hamano38064d52006-01-15 10:13:49390</dt>
391<dd>
392<p>
Junio C Hamanoe663a7a2006-01-25 12:37:28393 Make a <em>bare</em> GIT repository. That is, instead of
Junio C Hamano38064d52006-01-15 10:13:49394 creating <tt>&lt;directory&gt;</tt> and placing the administrative
395 files in <tt>&lt;directory&gt;/.git</tt>, make the <tt>&lt;directory&gt;</tt>
Junio C Hamano9f292e72006-11-24 11:37:29396 itself the <tt>$GIT_DIR</tt>. This obviously implies the <tt>-n</tt>
397 because there is nowhere to check out the working tree.
398 Also the branch heads at the remote are copied directly
399 to corresponding local branch heads, without mapping
400 them to <tt>refs/remotes/origin/</tt>. When this option is
Junio C Hamanod3361ad2007-01-01 03:20:24401 used, neither remote-tracking branches nor the related
402 configuration variables are created.
Junio C Hamano38064d52006-01-15 10:13:49403</p>
404</dd>
405<dt>
Junio C Hamanodcc22ee2006-11-03 02:40:13406--origin &lt;name&gt;
407</dt>
408<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23409-o &lt;name&gt;
410</dt>
411<dd>
412<p>
Junio C Hamanod3361ad2007-01-01 03:20:24413 Instead of using the remote name <em>origin</em> to keep track
414 of the upstream repository, use &lt;name&gt; instead.
Junio C Hamano1a4e8412005-12-27 08:17:23415</p>
416</dd>
417<dt>
418--upload-pack &lt;upload-pack&gt;
419</dt>
420<dt>
421-u &lt;upload-pack&gt;
422</dt>
423<dd>
424<p>
425 When given, and the repository to clone from is handled
Junio C Hamano97f518c2006-06-22 19:49:35426 by <em>git-fetch-pack</em>, <em>--exec=&lt;upload-pack&gt;</em> is passed to
Junio C Hamano1a4e8412005-12-27 08:17:23427 the command to specify non-default path for the command
428 run on the other end.
429</p>
430</dd>
431<dt>
Junio C Hamanof31d9f52006-05-28 20:58:09432--template=&lt;template_directory&gt;
433</dt>
434<dd>
435<p>
436 Specify the directory from which templates will be used;
437 if unset the templates are taken from the installation
438 defined default, typically <tt>/usr/share/git-core/templates</tt>.
439</p>
440</dd>
441<dt>
Junio C Hamano0bbd4672007-02-20 04:52:14442--depth &lt;depth&gt;
Junio C Hamanob288d9e2007-01-02 00:04:15443</dt>
444<dd>
445<p>
446 Create a <em>shallow</em> clone with a history truncated to the
Junio C Hamano1c708832007-11-02 02:47:50447 specified number of revisions. A shallow repository has a
Junio C Hamanob288d9e2007-01-02 00:04:15448 number of limitations (you cannot clone or fetch from
449 it, nor push from nor into it), but is adequate if you
Junio C Hamano1c708832007-11-02 02:47:50450 are only interested in the recent history of a large project
451 with a long history, and would want to send in fixes
Junio C Hamanob288d9e2007-01-02 00:04:15452 as patches.
453</p>
454</dd>
455<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23456&lt;repository&gt;
457</dt>
458<dd>
459<p>
Junio C Hamano330aae62007-07-06 17:01:58460 The (possibly remote) repository to clone from. See the
461 <a href="#URLS">URLS</a> section below for more information on specifying
462 repositories.
Junio C Hamano1a4e8412005-12-27 08:17:23463</p>
464</dd>
465<dt>
466&lt;directory&gt;
467</dt>
468<dd>
469<p>
470 The name of a new directory to clone into. The "humanish"
471 part of the source repository is used if no directory is
472 explicitly given ("repo" for "/path/to/repo.git" and "foo"
473 for "host.xz:foo/.git"). Cloning into an existing directory
474 is not allowed.
475</p>
476</dd>
477</dl>
Junio C Hamano1bb569e2006-05-05 23:14:25478</div>
Junio C Hamano330aae62007-07-06 17:01:58479<h2>GIT URLS<a id="URLS"></a></h2>
480<div class="sectionbody">
481<p>One of the following notations can be used
482to name the remote repository:</p>
483<div class="exampleblock">
484<div class="exampleblock-content">
485<ul>
486<li>
487<p>
488rsync://host.xz/path/to/repo.git/
489</p>
490</li>
491<li>
492<p>
493http://host.xz/path/to/repo.git/
494</p>
495</li>
496<li>
497<p>
498https://host.xz/path/to/repo.git/
499</p>
500</li>
501<li>
502<p>
503git://host.xz/path/to/repo.git/
504</p>
505</li>
506<li>
507<p>
508git://host.xz/~user/path/to/repo.git/
509</p>
510</li>
511<li>
512<p>
Junio C Hamanodbb64592007-09-01 11:17:39513ssh://&#91;user@&#93;host.xz&#91;:port&#93;/path/to/repo.git/
514</p>
515</li>
516<li>
517<p>
Junio C Hamano330aae62007-07-06 17:01:58518ssh://&#91;user@&#93;host.xz/path/to/repo.git/
519</p>
520</li>
521<li>
522<p>
523ssh://&#91;user@&#93;host.xz/~user/path/to/repo.git/
524</p>
525</li>
526<li>
527<p>
528ssh://&#91;user@&#93;host.xz/~/path/to/repo.git
529</p>
530</li>
531</ul>
532</div></div>
Junio C Hamanob1d6e882007-08-11 08:30:16533<p>SSH is the default transport protocol over the network. You can
534optionally specify which user to log-in as, and an alternate,
535scp-like syntax is also supported. Both syntaxes support
Junio C Hamanodbb64592007-09-01 11:17:39536username expansion, as does the native git protocol, but
537only the former supports port specification. The following
Junio C Hamanob1d6e882007-08-11 08:30:16538three are identical to the last three above, respectively:</p>
Junio C Hamano330aae62007-07-06 17:01:58539<div class="exampleblock">
540<div class="exampleblock-content">
541<ul>
542<li>
543<p>
544&#91;user@&#93;host.xz:/path/to/repo.git/
545</p>
546</li>
547<li>
548<p>
549&#91;user@&#93;host.xz:~user/path/to/repo.git/
550</p>
551</li>
552<li>
553<p>
554&#91;user@&#93;host.xz:path/to/repo.git
555</p>
556</li>
557</ul>
558</div></div>
Junio C Hamanob1d6e882007-08-11 08:30:16559<p>To sync with a local directory, you can use:</p>
Junio C Hamano330aae62007-07-06 17:01:58560<div class="exampleblock">
561<div class="exampleblock-content">
562<ul>
563<li>
564<p>
565/path/to/repo.git/
566</p>
567</li>
Junio C Hamanob1d6e882007-08-11 08:30:16568<li>
569<p>
570file:///path/to/repo.git/
571</p>
572</li>
Junio C Hamano330aae62007-07-06 17:01:58573</ul>
574</div></div>
Junio C Hamano63777e22007-11-17 20:52:16575<p>They are equivalent, except the former implies --local option.</p>
Junio C Hamano24bc09a2008-02-28 00:27:44576<p>If there are a large number of similarly-named remote repositories and
577you want to use a different format for them (such that the URLs you
578use will be rewritten into URLs that work), you can create a
579configuration section of the form:</p>
580<div class="listingblock">
581<div class="content">
582<pre><tt> [url "&lt;actual url base&gt;"]
583 insteadOf = &lt;other url base&gt;</tt></pre>
584</div></div>
585<p>For example, with this:</p>
586<div class="listingblock">
587<div class="content">
588<pre><tt> [url "git://git.host.xz/"]
589 insteadOf = host.xz:/path/to/
590 insteadOf = work:</tt></pre>
591</div></div>
592<p>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
593rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</p>
Junio C Hamano330aae62007-07-06 17:01:58594</div>
Junio C Hamano1bb569e2006-05-05 23:14:25595<h2>Examples</h2>
596<div class="sectionbody">
Junio C Hamano1a4e8412005-12-27 08:17:23597<dl>
598<dt>
599Clone from upstream
600</dt>
601<dd>
602<div class="listingblock">
603<div class="content">
604<pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
605$ cd my2.6
606$ make</tt></pre>
607</div></div>
608</dd>
609<dt>
610Make a local clone that borrows from the current directory, without checking things out
611</dt>
612<dd>
613<div class="listingblock">
614<div class="content">
615<pre><tt>$ git clone -l -s -n . ../copy
Junio C Hamano8638c922007-05-12 20:50:08616$ cd ../copy
Junio C Hamano1a4e8412005-12-27 08:17:23617$ git show-branch</tt></pre>
618</div></div>
619</dd>
Junio C Hamano38064d52006-01-15 10:13:49620<dt>
Junio C Hamanof50bfec2006-04-19 09:44:12621Clone from upstream while borrowing from an existing local directory
622</dt>
623<dd>
624<div class="listingblock">
625<div class="content">
626<pre><tt>$ git clone --reference my2.6 \
627 git://git.kernel.org/pub/scm/.../linux-2.7 \
628 my2.7
629$ cd my2.7</tt></pre>
630</div></div>
631</dd>
632<dt>
Junio C Hamanoe663a7a2006-01-25 12:37:28633Create a bare repository to publish your changes to the public
Junio C Hamano38064d52006-01-15 10:13:49634</dt>
635<dd>
636<div class="listingblock">
637<div class="content">
Junio C Hamanoe663a7a2006-01-25 12:37:28638<pre><tt>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git</tt></pre>
Junio C Hamano38064d52006-01-15 10:13:49639</div></div>
640</dd>
641<dt>
642Create a repository on the kernel.org machine that borrows from Linus
643</dt>
644<dd>
645<div class="listingblock">
646<div class="content">
Junio C Hamanoe663a7a2006-01-25 12:37:28647<pre><tt>$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
Junio C Hamano38064d52006-01-15 10:13:49648 /pub/scm/.../me/subsys-2.6.git</tt></pre>
649</div></div>
650</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23651</dl>
652</div>
653<h2>Author</h2>
654<div class="sectionbody">
655<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
656</div>
657<h2>Documentation</h2>
658<div class="sectionbody">
659<p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
660</div>
661<h2>GIT</h2>
662<div class="sectionbody">
663<p>Part of the <a href="git.html">git(7)</a> suite</p>
664</div>
665<div id="footer">
666<div id="footer-text">
Junio C Hamano24bc09a2008-02-28 00:27:44667Last updated 28-Feb-2008 00:25:37 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23668</div>
669</div>
670</body>
671</html>