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">
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">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
66 border: 1px solid silver
;
81 font-family: sans-serif
;
88 font-family: sans-serif
;
92 font-family: sans-serif
;
94 border-top: 2px solid silver
;
100 padding-bottom: 0.5em;
104 padding-bottom: 0.5em;
108 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
109 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
110 div
.admonitionblock
{
113 margin-bottom: 1.5em;
115 div
.admonitionblock
{
117 margin-bottom: 2.5em;
120 div
.content
{ /* Block element content. */
124 /* Block element titles. */
125 div
.title
, caption
.title
{
126 font-family: sans-serif
;
130 margin-bottom: 0.5em;
136 td div
.title:first-child
{
139 div
.content div
.title:first-child
{
142 div
.content
+ div
.title
{
146 div
.sidebarblock
> div
.content
{
148 border: 1px solid silver
;
155 div
.listingblock
> div
.content
{
156 border: 1px solid silver
;
161 div
.quoteblock
> div
.content
{
168 div
.verseblock
+ div
.attribution
{
172 div
.admonitionblock
.icon
{
176 text-decoration: underline
;
178 padding-right: 0.5em;
180 div
.admonitionblock td
.content
{
182 border-left: 2px solid silver
;
185 div
.exampleblock
> div
.content
{
186 border-left: 2px solid silver
;
190 div
.verseblock div
.content
{
194 div
.imageblock div
.content
{ padding-left: 0; }
195 div
.imageblock img
{ border: 1px solid silver
; }
196 span
.image img
{ border-style: none
; }
200 margin-bottom: 0.8em;
212 list-style-position: outside
;
215 list-style-type: lower-alpha
;
218 div
.tableblock
> table
{
219 border: 3px solid
#527bbd;
222 font-family: sans-serif
;
231 margin-bottom: 0.8em;
239 padding-right: 0.8em;
246 div#footer-badges
{ display: none
; }
251 font-family: sans-serif
;
255 margin-bottom: 0.1em;
258 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
274 include1::./stylesheets
/xhtml11-manpage
.css
[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div
.sidebar-content
{
279 border: 1px solid silver
;
282 div
.sidebar-title
, div
.image-title
{
283 font-family: sans-serif
;
286 margin-bottom: 0.5em;
289 div
.listingblock div
.content
{
290 border: 1px solid silver
;
295 div
.quoteblock-content
{
299 div
.exampleblock-content
{
300 border-left: 2px solid silver
;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc
a:visited
{ color: blue
; }
307 <title>git-clone(
1)
</title>
312 git-clone(
1) Manual Page
315 <div class=
"sectionbody">
317 Clone a repository into a new directory
322 <div class=
"sectionbody">
323 <div class=
"verseblock">
324 <div class=
"content"><em>git clone
</em> [--template=
<template_directory
>]
325 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
326 [-o
<name
>] [-b
<name
>] [-u
<upload-pack
>] [--reference
<repository
>]
327 [--depth
<depth
>] [--recursive] [--]
<repository
> [
<directory
>]
</div></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>$GIT_DIR/refs/remotes/origin
</tt> and
342 by initializing
<tt>remote.origin.url
</tt> and
<tt>remote.origin.fetch
</tt>
343 configuration variables.
</p></div>
345 <h2 id=
"_options">OPTIONS
</h2>
346 <div class=
"sectionbody">
347 <div class=
"vlist"><dl>
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.
375 Optimize the cloning process from a repository on a
376 local filesystem by copying files under
<tt>.git/objects
</tt>
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.
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
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>
413 --reference
<repository
>
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.
424 <div class=
"para"><p><strong>NOTE
</strong>: see the NOTE for the
<tt>--shared
</tt> option.
</p></div>
434 Operate quietly. This flag is also passed to the `rsync'
446 Display the progress bar, even in case the standard output is not
458 No checkout of HEAD is performed after the clone is complete.
466 Make a
<em>bare
</em> GIT repository. That is, instead of
467 creating
<tt><directory
></tt> and placing the administrative
468 files in
<tt><directory
>/.git
</tt>, make the
<tt><directory
></tt>
469 itself the
<tt>$GIT_DIR
</tt>. This obviously implies the
<tt>-n
</tt>
470 because there is nowhere to check out the working tree.
471 Also the branch heads at the remote are copied directly
472 to corresponding local branch heads, without mapping
473 them to
<tt>refs/remotes/origin/
</tt>. When this option is
474 used, neither remote-tracking branches nor the related
475 configuration variables are created.
483 Set up a mirror of the remote repository. This implies
<tt>--bare
</tt>.
487 --origin
<name
>
494 Instead of using the remote name
<tt>origin
</tt> to keep track
495 of the upstream repository, use
<tt><name
></tt>.
499 --branch
<name
>
506 Instead of pointing the newly created HEAD to the branch pointed
507 to by the cloned repository's HEAD, point to
<tt><name
></tt> branch
508 instead. In a non-bare repository, this is the branch that will
513 --upload-pack
<upload-pack
>
516 -u
<upload-pack
>
520 When given, and the repository to clone from is accessed
521 via ssh, this specifies a non-default path for the command
522 run on the other end.
526 --template=
<template_directory
>
530 Specify the directory from which templates will be used;
531 if unset the templates are taken from the installation
532 defined default, typically
<tt>/usr/share/git-core/templates
</tt>.
536 --depth
<depth
>
540 Create a
<em>shallow
</em> clone with a history truncated to the
541 specified number of revisions. A shallow repository has a
542 number of limitations (you cannot clone or fetch from
543 it, nor push from nor into it), but is adequate if you
544 are only interested in the recent history of a large project
545 with a long history, and would want to send in fixes
554 After the clone is created, initialize all submodules within,
555 using their default settings. This is equivalent to running
556 <tt>git submodule update --init --recursive
</tt> immediately after
557 the clone is finished. This option is ignored if the cloned
558 repository does not have a worktree/checkout (i.e. if any of
559 <tt>--no-checkout
</tt>/
<tt>-n
</tt>,
<tt>--bare
</tt>, or
<tt>--mirror
</tt> is given)
567 The (possibly remote) repository to clone from. See the
568 <a href=
"#URLS">URLS
</a> section below for more information on specifying
577 The name of a new directory to clone into. The
"humanish"
578 part of the source repository is used if no directory is
579 explicitly given (
<tt>repo
</tt> for
<tt>/path/to/repo.git
</tt> and
<tt>foo
</tt>
580 for
<tt>host.xz:foo/.git
</tt>). Cloning into an existing directory
581 is only allowed if the directory is empty.
586 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
587 <div class=
"sectionbody">
588 <div class=
"para"><p>One of the following notations can be used
589 to name the remote repository:
</p></div>
590 <div class=
"exampleblock">
591 <div class=
"exampleblock-content">
592 <div class=
"ilist"><ul>
595 rsync://host.xz/path/to/repo.git/
600 http://host.xz
[:port
]/path/to/repo.git/
605 https://host.xz
[:port
]/path/to/repo.git/
610 git://host.xz
[:port
]/path/to/repo.git/
615 git://host.xz
[:port
]/~user/path/to/repo.git/
620 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
625 ssh://
[user@
]host.xz/path/to/repo.git/
630 ssh://
[user@
]host.xz/~user/path/to/repo.git/
635 ssh://
[user@
]host.xz/~/path/to/repo.git
640 <div class=
"para"><p>SSH is the default transport protocol over the network. You can
641 optionally specify which user to log-in as, and an alternate,
642 scp-like syntax is also supported. Both syntaxes support
643 username expansion, as does the native git protocol, but
644 only the former supports port specification. The following
645 three are identical to the last three above, respectively:
</p></div>
646 <div class=
"exampleblock">
647 <div class=
"exampleblock-content">
648 <div class=
"ilist"><ul>
651 [user@
]host.xz:/path/to/repo.git/
656 [user@
]host.xz:~user/path/to/repo.git/
661 [user@
]host.xz:path/to/repo.git
666 <div class=
"para"><p>To sync with a local directory, you can use:
</p></div>
667 <div class=
"exampleblock">
668 <div class=
"exampleblock-content">
669 <div class=
"ilist"><ul>
677 file:///path/to/repo.git/
682 <div class=
"para"><p>They are equivalent, except the former implies --local option.
</p></div>
683 <div class=
"para"><p>If there are a large number of similarly-named remote repositories and
684 you want to use a different format for them (such that the URLs you
685 use will be rewritten into URLs that work), you can create a
686 configuration section of the form:
</p></div>
687 <div class=
"listingblock">
688 <div class=
"content">
689 <pre><tt> [url
"<actual url base>"]
690 insteadOf =
<other url base
></tt></pre>
692 <div class=
"para"><p>For example, with this:
</p></div>
693 <div class=
"listingblock">
694 <div class=
"content">
695 <pre><tt> [url
"git://git.host.xz/"]
696 insteadOf = host.xz:/path/to/
697 insteadOf = work:
</tt></pre>
699 <div class=
"para"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
700 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
701 <div class=
"para"><p>If you want to rewrite URLs for push only, you can create a
702 configuration section of the form:
</p></div>
703 <div class=
"listingblock">
704 <div class=
"content">
705 <pre><tt> [url
"<actual url base>"]
706 pushInsteadOf =
<other url base
></tt></pre>
708 <div class=
"para"><p>For example, with this:
</p></div>
709 <div class=
"listingblock">
710 <div class=
"content">
711 <pre><tt> [url
"ssh://example.org/"]
712 pushInsteadOf = git://example.org/
</tt></pre>
714 <div class=
"para"><p>a URL like
"git://example.org/path/to/repo.git" will be rewritten to
715 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
716 use the original URL.
</p></div>
718 <h2 id=
"_examples">Examples
</h2>
719 <div class=
"sectionbody">
720 <div class=
"vlist"><dl>
725 <div class=
"listingblock">
726 <div class=
"content">
727 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-
2.6 my2.6
733 Make a local clone that borrows from the current directory, without checking things out
736 <div class=
"listingblock">
737 <div class=
"content">
738 <pre><tt>$ git clone -l -s -n . ../copy
740 $ git show-branch
</tt></pre>
744 Clone from upstream while borrowing from an existing local directory
747 <div class=
"listingblock">
748 <div class=
"content">
749 <pre><tt>$ git clone --reference my2.6 \
750 git://git.kernel.org/pub/scm/.../linux-
2.7 \
752 $ cd my2.7
</tt></pre>
756 Create a bare repository to publish your changes to the public
759 <div class=
"listingblock">
760 <div class=
"content">
761 <pre><tt>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
</tt></pre>
765 Create a repository on the kernel.org machine that borrows from Linus
768 <div class=
"listingblock">
769 <div class=
"content">
770 <pre><tt>$ git clone --bare -l -s /pub/scm/.../torvalds/linux-
2.6.git \
771 /pub/scm/.../me/subsys-
2.6.git
</tt></pre>
776 <h2 id=
"_author">Author
</h2>
777 <div class=
"sectionbody">
778 <div class=
"para"><p>Written by Linus Torvalds
<torvalds@osdl.org
></p></div>
780 <h2 id=
"_documentation">Documentation
</h2>
781 <div class=
"sectionbody">
782 <div class=
"para"><p>Documentation by Junio C Hamano and the git-list
<git@vger.kernel.org
>.
</p></div>
784 <h2 id=
"_git">GIT
</h2>
785 <div class=
"sectionbody">
786 <div class=
"para"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
789 <div id=
"footer-text">
790 Last updated
2009-
12-
03 09:
12:
29 UTC