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.4.5" />
7 <title>git-clone(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-clone(
1) Manual Page
409 <div class=
"sectionbody">
411 Clone a repository into a new directory
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"verseblock">
418 <div class=
"verseblock-content"><em>git clone
</em> [--template=
<template_directory
>]
419 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
420 [-o
<name
>] [-b
<name
>] [-u
<upload-pack
>] [--reference
<repository
>]
421 [--depth
<depth
>] [--recursive|--recurse-submodules] [--]
<repository
>
422 [
<directory
>]
</div>
423 <div class=
"verseblock-attribution">
426 <h2 id=
"_description">DESCRIPTION
</h2>
427 <div class=
"sectionbody">
428 <div class=
"paragraph"><p>Clones a repository into a newly created directory, creates
429 remote-tracking branches for each branch in the cloned repository
430 (visible using
<tt>git branch -r
</tt>), and creates and checks out an
431 initial branch that is forked from the cloned repository
’s
432 currently active branch.
</p></div>
433 <div class=
"paragraph"><p>After the clone, a plain
<tt>git fetch
</tt> without arguments will update
434 all the remote-tracking branches, and a
<tt>git pull
</tt> without
435 arguments will in addition merge the remote master branch into the
436 current master branch, if any.
</p></div>
437 <div class=
"paragraph"><p>This default configuration is achieved by creating references to
438 the remote branch heads under
<tt>refs/remotes/origin
</tt> and
439 by initializing
<tt>remote.origin.url
</tt> and
<tt>remote.origin.fetch
</tt>
440 configuration variables.
</p></div>
442 <h2 id=
"_options">OPTIONS
</h2>
443 <div class=
"sectionbody">
444 <div class=
"dlist"><dl>
453 When the repository to clone from is on a local machine,
454 this flag bypasses the normal
"git aware" transport
455 mechanism and clones the repository by making a copy of
456 HEAD and everything under objects and refs directories.
457 The files under
<tt>.git/objects/
</tt> directory are hardlinked
458 to save space when possible. This is now the default when
459 the source repository is specified with
<tt>/path/to/repo
</tt>
460 syntax, so it essentially is a no-op option. To force
461 copying instead of hardlinking (which may be desirable
462 if you are trying to make a back-up of your repository),
463 but still avoid the usual
"git aware" transport
464 mechanism,
<tt>--no-hardlinks
</tt> can be used.
472 Optimize the cloning process from a repository on a
473 local filesystem by copying files under
<tt>.git/objects
</tt>
485 When the repository to clone is on the local machine,
486 instead of using hard links, automatically setup
487 <tt>.git/objects/info/alternates
</tt> to share the objects
488 with the source repository. The resulting repository
489 starts out without any object of its own.
491 <div class=
"paragraph"><p><strong>NOTE
</strong>: this is a possibly dangerous operation; do
<strong>not
</strong> use
492 it unless you understand what it does. If you clone your
493 repository using this option and then delete branches (or use any
494 other git command that makes any existing commit unreferenced) in the
495 source repository, some objects may become unreferenced (or dangling).
496 These objects may be removed by normal git operations (such as
<tt>git commit
</tt>)
497 which automatically call
<tt>git gc --auto
</tt>. (See
<a href=
"git-gc.html">git-gc(
1)
</a>.)
498 If these objects are removed and were referenced by the cloned repository,
499 then the cloned repository will become corrupt.
</p></div>
500 <div class=
"paragraph"><p>Note that running
<tt>git repack
</tt> without the
<tt>-l
</tt> option in a repository
501 cloned with
<tt>-s
</tt> will copy objects from the source repository into a pack
502 in the cloned repository, removing the disk space savings of
<tt>clone -s
</tt>.
503 It is safe, however, to run
<tt>git gc
</tt>, which uses the
<tt>-l
</tt> option by
505 <div class=
"paragraph"><p>If you want to break the dependency of a repository cloned with
<tt>-s
</tt> on
506 its source repository, you can simply run
<tt>git repack -a
</tt> to copy all
507 objects from the source repository into a pack in the cloned repository.
</p></div>
510 --reference
<repository
>
514 If the reference repository is on the local machine,
515 automatically setup
<tt>.git/objects/info/alternates
</tt> to
516 obtain objects from the reference repository. Using
517 an already existing repository as an alternate will
518 require fewer objects to be copied from the repository
519 being cloned, reducing network and local storage costs.
521 <div class=
"paragraph"><p><strong>NOTE
</strong>: see the NOTE for the
<tt>--shared
</tt> option.
</p></div>
531 Operate quietly. Progress is not reported to the standard
532 error stream. This flag is also passed to the
‘rsync
’
544 Run verbosely. Does not affect the reporting of progress status
545 to the standard error stream.
553 Progress status is reported on the standard error stream
554 by default when it is attached to a terminal, unless -q
555 is specified. This flag forces progress status even if the
556 standard error stream is not directed to a terminal.
567 No checkout of HEAD is performed after the clone is complete.
575 Make a
<em>bare
</em> GIT repository. That is, instead of
576 creating
<tt><directory
></tt> and placing the administrative
577 files in
<tt><directory
>/.git
</tt>, make the
<tt><directory
></tt>
578 itself the
<tt>$GIT_DIR
</tt>. This obviously implies the
<tt>-n
</tt>
579 because there is nowhere to check out the working tree.
580 Also the branch heads at the remote are copied directly
581 to corresponding local branch heads, without mapping
582 them to
<tt>refs/remotes/origin/
</tt>. When this option is
583 used, neither remote-tracking branches nor the related
584 configuration variables are created.
592 Set up a mirror of the source repository. This implies
<tt>--bare
</tt>.
593 Compared to
<tt>--bare
</tt>,
<tt>--mirror
</tt> not only maps local branches of the
594 source to local branches of the target, it maps all refs (including
595 remote-tracking branches, notes etc.) and sets up a refspec configuration such
596 that all these refs are overwritten by a
<tt>git remote update
</tt> in the
601 --origin
<name
>
608 Instead of using the remote name
<tt>origin
</tt> to keep track
609 of the upstream repository, use
<tt><name
></tt>.
613 --branch
<name
>
620 Instead of pointing the newly created HEAD to the branch pointed
621 to by the cloned repository
’s HEAD, point to
<tt><name
></tt> branch
622 instead. In a non-bare repository, this is the branch that will
627 --upload-pack
<upload-pack
>
630 -u
<upload-pack
>
634 When given, and the repository to clone from is accessed
635 via ssh, this specifies a non-default path for the command
636 run on the other end.
640 --template=
<template_directory
>
644 Specify the directory from which templates will be used;
645 (See the
"TEMPLATE DIRECTORY" section of
<a href=
"git-init.html">git-init(
1)
</a>.)
649 --depth
<depth
>
653 Create a
<em>shallow
</em> clone with a history truncated to the
654 specified number of revisions. A shallow repository has a
655 number of limitations (you cannot clone or fetch from
656 it, nor push from nor into it), but is adequate if you
657 are only interested in the recent history of a large project
658 with a long history, and would want to send in fixes
670 After the clone is created, initialize all submodules within,
671 using their default settings. This is equivalent to running
672 <tt>git submodule update --init --recursive
</tt> immediately after
673 the clone is finished. This option is ignored if the cloned
674 repository does not have a worktree/checkout (i.e. if any of
675 <tt>--no-checkout
</tt>/
<tt>-n
</tt>,
<tt>--bare
</tt>, or
<tt>--mirror
</tt> is given)
683 The (possibly remote) repository to clone from. See the
684 <a href=
"#URLS">URLS
</a> section below for more information on specifying
693 The name of a new directory to clone into. The
"humanish"
694 part of the source repository is used if no directory is
695 explicitly given (
<tt>repo
</tt> for
<tt>/path/to/repo.git
</tt> and
<tt>foo
</tt>
696 for
<tt>host.xz:foo/.git
</tt>). Cloning into an existing directory
697 is only allowed if the directory is empty.
702 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
703 <div class=
"sectionbody">
704 <div class=
"paragraph"><p>In general, URLs contain information about the transport protocol, the
705 address of the remote server, and the path to the repository.
706 Depending on the transport protocol, some of this information may be
708 <div class=
"paragraph"><p>Git natively supports ssh, git, http, https, ftp, ftps, and rsync
709 protocols. The following syntaxes may be used with them:
</p></div>
710 <div class=
"ulist"><ul>
713 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
718 git://host.xz
[:port
]/path/to/repo.git/
723 http
[s
]://host.xz
[:port
]/path/to/repo.git/
728 ftp
[s
]://host.xz
[:port
]/path/to/repo.git/
733 rsync://host.xz/path/to/repo.git/
737 <div class=
"paragraph"><p>An alternative scp-like syntax may also be used with the ssh protocol:
</p></div>
738 <div class=
"ulist"><ul>
741 [user@
]host.xz:path/to/repo.git/
745 <div class=
"paragraph"><p>The ssh and git protocols additionally support ~username expansion:
</p></div>
746 <div class=
"ulist"><ul>
749 ssh://
[user@
]host.xz
[:port
]/~
[user
]/path/to/repo.git/
754 git://host.xz
[:port
]/~
[user
]/path/to/repo.git/
759 [user@
]host.xz:/~
[user
]/path/to/repo.git/
763 <div class=
"paragraph"><p>For local repositories, also supported by git natively, the following
764 syntaxes may be used:
</p></div>
765 <div class=
"ulist"><ul>
773 <a href=
"file:///path/to/repo.git/">file:///path/to/repo.git/
</a>
777 <div class=
"paragraph"><p>These two syntaxes are mostly equivalent, except the former implies
778 --local option.
</p></div>
779 <div class=
"paragraph"><p>When git doesn
’t know how to handle a certain transport protocol, it
780 attempts to use the
<em>remote-
<transport
></em> remote helper, if one
781 exists. To explicitly request a remote helper, the following syntax
782 may be used:
</p></div>
783 <div class=
"ulist"><ul>
786 <transport
>::
<address
>
790 <div class=
"paragraph"><p>where
<address
> may be a path, a server and path, or an arbitrary
791 URL-like string recognized by the specific remote helper being
792 invoked. See
<a href=
"git-remote-helpers.html">git-remote-helpers(
1)
</a> for details.
</p></div>
793 <div class=
"paragraph"><p>If there are a large number of similarly-named remote repositories and
794 you want to use a different format for them (such that the URLs you
795 use will be rewritten into URLs that work), you can create a
796 configuration section of the form:
</p></div>
797 <div class=
"listingblock">
798 <div class=
"content">
799 <pre><tt> [url
"<actual url base>"]
800 insteadOf =
<other url base
></tt></pre>
802 <div class=
"paragraph"><p>For example, with this:
</p></div>
803 <div class=
"listingblock">
804 <div class=
"content">
805 <pre><tt> [url
"git://git.host.xz/"]
806 insteadOf = host.xz:/path/to/
807 insteadOf = work:
</tt></pre>
809 <div class=
"paragraph"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
810 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
811 <div class=
"paragraph"><p>If you want to rewrite URLs for push only, you can create a
812 configuration section of the form:
</p></div>
813 <div class=
"listingblock">
814 <div class=
"content">
815 <pre><tt> [url
"<actual url base>"]
816 pushInsteadOf =
<other url base
></tt></pre>
818 <div class=
"paragraph"><p>For example, with this:
</p></div>
819 <div class=
"listingblock">
820 <div class=
"content">
821 <pre><tt> [url
"ssh://example.org/"]
822 pushInsteadOf = git://example.org/
</tt></pre>
824 <div class=
"paragraph"><p>a URL like
"git://example.org/path/to/repo.git" will be rewritten to
825 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
826 use the original URL.
</p></div>
828 <h2 id=
"_examples">Examples
</h2>
829 <div class=
"sectionbody">
830 <div class=
"ulist"><ul>
835 <div class=
"listingblock">
836 <div class=
"content">
837 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-
2.6 my2.6
844 Make a local clone that borrows from the current directory, without checking things out:
846 <div class=
"listingblock">
847 <div class=
"content">
848 <pre><tt>$ git clone -l -s -n . ../copy
850 $ git show-branch
</tt></pre>
855 Clone from upstream while borrowing from an existing local directory:
857 <div class=
"listingblock">
858 <div class=
"content">
859 <pre><tt>$ git clone --reference my2.6 \
860 git://git.kernel.org/pub/scm/.../linux-
2.7 \
862 $ cd my2.7
</tt></pre>
867 Create a bare repository to publish your changes to the public:
869 <div class=
"listingblock">
870 <div class=
"content">
871 <pre><tt>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
</tt></pre>
876 Create a repository on the kernel.org machine that borrows from Linus:
878 <div class=
"listingblock">
879 <div class=
"content">
880 <pre><tt>$ git clone --bare -l -s /pub/scm/.../torvalds/linux-
2.6.git \
881 /pub/scm/.../me/subsys-
2.6.git
</tt></pre>
886 <h2 id=
"_git">GIT
</h2>
887 <div class=
"sectionbody">
888 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
891 <div id=
"footer-text">
892 Last updated
2011-
03-
15 23:
30:
13 UTC