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 [--separate-git-dir|-L
<git dir
>]
422 [--depth
<depth
>] [--recursive|--recurse-submodules] [--]
<repository
>
423 [
<directory
>]
</div>
424 <div class=
"verseblock-attribution">
427 <h2 id=
"_description">DESCRIPTION
</h2>
428 <div class=
"sectionbody">
429 <div class=
"paragraph"><p>Clones a repository into a newly created directory, creates
430 remote-tracking branches for each branch in the cloned repository
431 (visible using
<tt>git branch -r
</tt>), and creates and checks out an
432 initial branch that is forked from the cloned repository
’s
433 currently active branch.
</p></div>
434 <div class=
"paragraph"><p>After the clone, a plain
<tt>git fetch
</tt> without arguments will update
435 all the remote-tracking branches, and a
<tt>git pull
</tt> without
436 arguments will in addition merge the remote master branch into the
437 current master branch, if any.
</p></div>
438 <div class=
"paragraph"><p>This default configuration is achieved by creating references to
439 the remote branch heads under
<tt>refs/remotes/origin
</tt> and
440 by initializing
<tt>remote.origin.url
</tt> and
<tt>remote.origin.fetch
</tt>
441 configuration variables.
</p></div>
443 <h2 id=
"_options">OPTIONS
</h2>
444 <div class=
"sectionbody">
445 <div class=
"dlist"><dl>
454 When the repository to clone from is on a local machine,
455 this flag bypasses the normal
"git aware" transport
456 mechanism and clones the repository by making a copy of
457 HEAD and everything under objects and refs directories.
458 The files under
<tt>.git/objects/
</tt> directory are hardlinked
459 to save space when possible. This is now the default when
460 the source repository is specified with
<tt>/path/to/repo
</tt>
461 syntax, so it essentially is a no-op option. To force
462 copying instead of hardlinking (which may be desirable
463 if you are trying to make a back-up of your repository),
464 but still avoid the usual
"git aware" transport
465 mechanism,
<tt>--no-hardlinks
</tt> can be used.
473 Optimize the cloning process from a repository on a
474 local filesystem by copying files under
<tt>.git/objects
</tt>
486 When the repository to clone is on the local machine,
487 instead of using hard links, automatically setup
488 <tt>.git/objects/info/alternates
</tt> to share the objects
489 with the source repository. The resulting repository
490 starts out without any object of its own.
492 <div class=
"paragraph"><p><strong>NOTE
</strong>: this is a possibly dangerous operation; do
<strong>not
</strong> use
493 it unless you understand what it does. If you clone your
494 repository using this option and then delete branches (or use any
495 other git command that makes any existing commit unreferenced) in the
496 source repository, some objects may become unreferenced (or dangling).
497 These objects may be removed by normal git operations (such as
<tt>git commit
</tt>)
498 which automatically call
<tt>git gc --auto
</tt>. (See
<a href=
"git-gc.html">git-gc(
1)
</a>.)
499 If these objects are removed and were referenced by the cloned repository,
500 then the cloned repository will become corrupt.
</p></div>
501 <div class=
"paragraph"><p>Note that running
<tt>git repack
</tt> without the
<tt>-l
</tt> option in a repository
502 cloned with
<tt>-s
</tt> will copy objects from the source repository into a pack
503 in the cloned repository, removing the disk space savings of
<tt>clone -s
</tt>.
504 It is safe, however, to run
<tt>git gc
</tt>, which uses the
<tt>-l
</tt> option by
506 <div class=
"paragraph"><p>If you want to break the dependency of a repository cloned with
<tt>-s
</tt> on
507 its source repository, you can simply run
<tt>git repack -a
</tt> to copy all
508 objects from the source repository into a pack in the cloned repository.
</p></div>
511 --reference
<repository
>
515 If the reference repository is on the local machine,
516 automatically setup
<tt>.git/objects/info/alternates
</tt> to
517 obtain objects from the reference repository. Using
518 an already existing repository as an alternate will
519 require fewer objects to be copied from the repository
520 being cloned, reducing network and local storage costs.
522 <div class=
"paragraph"><p><strong>NOTE
</strong>: see the NOTE for the
<tt>--shared
</tt> option.
</p></div>
532 Operate quietly. Progress is not reported to the standard
533 error stream. This flag is also passed to the
‘rsync
’
545 Run verbosely. Does not affect the reporting of progress status
546 to the standard error stream.
554 Progress status is reported on the standard error stream
555 by default when it is attached to a terminal, unless -q
556 is specified. This flag forces progress status even if the
557 standard error stream is not directed to a terminal.
568 No checkout of HEAD is performed after the clone is complete.
576 Make a
<em>bare
</em> GIT repository. That is, instead of
577 creating
<tt><directory
></tt> and placing the administrative
578 files in
<tt><directory
>/.git
</tt>, make the
<tt><directory
></tt>
579 itself the
<tt>$GIT_DIR
</tt>. This obviously implies the
<tt>-n
</tt>
580 because there is nowhere to check out the working tree.
581 Also the branch heads at the remote are copied directly
582 to corresponding local branch heads, without mapping
583 them to
<tt>refs/remotes/origin/
</tt>. When this option is
584 used, neither remote-tracking branches nor the related
585 configuration variables are created.
593 Set up a mirror of the source repository. This implies
<tt>--bare
</tt>.
594 Compared to
<tt>--bare
</tt>,
<tt>--mirror
</tt> not only maps local branches of the
595 source to local branches of the target, it maps all refs (including
596 remote-tracking branches, notes etc.) and sets up a refspec configuration such
597 that all these refs are overwritten by a
<tt>git remote update
</tt> in the
602 --origin
<name
>
609 Instead of using the remote name
<tt>origin
</tt> to keep track
610 of the upstream repository, use
<tt><name
></tt>.
614 --branch
<name
>
621 Instead of pointing the newly created HEAD to the branch pointed
622 to by the cloned repository
’s HEAD, point to
<tt><name
></tt> branch
623 instead. In a non-bare repository, this is the branch that will
628 --upload-pack
<upload-pack
>
631 -u
<upload-pack
>
635 When given, and the repository to clone from is accessed
636 via ssh, this specifies a non-default path for the command
637 run on the other end.
641 --template=
<template_directory
>
645 Specify the directory from which templates will be used;
646 (See the
"TEMPLATE DIRECTORY" section of
<a href=
"git-init.html">git-init(
1)
</a>.)
650 --depth
<depth
>
654 Create a
<em>shallow
</em> clone with a history truncated to the
655 specified number of revisions. A shallow repository has a
656 number of limitations (you cannot clone or fetch from
657 it, nor push from nor into it), but is adequate if you
658 are only interested in the recent history of a large project
659 with a long history, and would want to send in fixes
671 After the clone is created, initialize all submodules within,
672 using their default settings. This is equivalent to running
673 <tt>git submodule update --init --recursive
</tt> immediately after
674 the clone is finished. This option is ignored if the cloned
675 repository does not have a worktree/checkout (i.e. if any of
676 <tt>--no-checkout
</tt>/
<tt>-n
</tt>,
<tt>--bare
</tt>, or
<tt>--mirror
</tt> is given)
683 --separate-git-dir=
<git dir
>
687 Instead of placing the cloned repository where it is supposed
688 to be, place the cloned repository at the specified directory,
689 then make a filesytem-agnostic git symbolic link to there.
690 The result is git repository can be separated from working
699 The (possibly remote) repository to clone from. See the
700 <a href=
"#URLS">URLS
</a> section below for more information on specifying
709 The name of a new directory to clone into. The
"humanish"
710 part of the source repository is used if no directory is
711 explicitly given (
<tt>repo
</tt> for
<tt>/path/to/repo.git
</tt> and
<tt>foo
</tt>
712 for
<tt>host.xz:foo/.git
</tt>). Cloning into an existing directory
713 is only allowed if the directory is empty.
718 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
719 <div class=
"sectionbody">
720 <div class=
"paragraph"><p>In general, URLs contain information about the transport protocol, the
721 address of the remote server, and the path to the repository.
722 Depending on the transport protocol, some of this information may be
724 <div class=
"paragraph"><p>Git natively supports ssh, git, http, https, ftp, ftps, and rsync
725 protocols. The following syntaxes may be used with them:
</p></div>
726 <div class=
"ulist"><ul>
729 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
734 git://host.xz
[:port
]/path/to/repo.git/
739 http
[s
]://host.xz
[:port
]/path/to/repo.git/
744 ftp
[s
]://host.xz
[:port
]/path/to/repo.git/
749 rsync://host.xz/path/to/repo.git/
753 <div class=
"paragraph"><p>An alternative scp-like syntax may also be used with the ssh protocol:
</p></div>
754 <div class=
"ulist"><ul>
757 [user@
]host.xz:path/to/repo.git/
761 <div class=
"paragraph"><p>The ssh and git protocols additionally support ~username expansion:
</p></div>
762 <div class=
"ulist"><ul>
765 ssh://
[user@
]host.xz
[:port
]/~
[user
]/path/to/repo.git/
770 git://host.xz
[:port
]/~
[user
]/path/to/repo.git/
775 [user@
]host.xz:/~
[user
]/path/to/repo.git/
779 <div class=
"paragraph"><p>For local repositories, also supported by git natively, the following
780 syntaxes may be used:
</p></div>
781 <div class=
"ulist"><ul>
789 <a href=
"file:///path/to/repo.git/">file:///path/to/repo.git/
</a>
793 <div class=
"paragraph"><p>These two syntaxes are mostly equivalent, except the former implies
794 --local option.
</p></div>
795 <div class=
"paragraph"><p>When git doesn
’t know how to handle a certain transport protocol, it
796 attempts to use the
<em>remote-
<transport
></em> remote helper, if one
797 exists. To explicitly request a remote helper, the following syntax
798 may be used:
</p></div>
799 <div class=
"ulist"><ul>
802 <transport
>::
<address
>
806 <div class=
"paragraph"><p>where
<address
> may be a path, a server and path, or an arbitrary
807 URL-like string recognized by the specific remote helper being
808 invoked. See
<a href=
"git-remote-helpers.html">git-remote-helpers(
1)
</a> for details.
</p></div>
809 <div class=
"paragraph"><p>If there are a large number of similarly-named remote repositories and
810 you want to use a different format for them (such that the URLs you
811 use will be rewritten into URLs that work), 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 insteadOf =
<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
"git://git.host.xz/"]
822 insteadOf = host.xz:/path/to/
823 insteadOf = work:
</tt></pre>
825 <div class=
"paragraph"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
826 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
827 <div class=
"paragraph"><p>If you want to rewrite URLs for push only, you can create a
828 configuration section of the form:
</p></div>
829 <div class=
"listingblock">
830 <div class=
"content">
831 <pre><tt> [url
"<actual url base>"]
832 pushInsteadOf =
<other url base
></tt></pre>
834 <div class=
"paragraph"><p>For example, with this:
</p></div>
835 <div class=
"listingblock">
836 <div class=
"content">
837 <pre><tt> [url
"ssh://example.org/"]
838 pushInsteadOf = git://example.org/
</tt></pre>
840 <div class=
"paragraph"><p>a URL like
"git://example.org/path/to/repo.git" will be rewritten to
841 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
842 use the original URL.
</p></div>
844 <h2 id=
"_examples">Examples
</h2>
845 <div class=
"sectionbody">
846 <div class=
"ulist"><ul>
851 <div class=
"listingblock">
852 <div class=
"content">
853 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-
2.6 my2.6
860 Make a local clone that borrows from the current directory, without checking things out:
862 <div class=
"listingblock">
863 <div class=
"content">
864 <pre><tt>$ git clone -l -s -n . ../copy
866 $ git show-branch
</tt></pre>
871 Clone from upstream while borrowing from an existing local directory:
873 <div class=
"listingblock">
874 <div class=
"content">
875 <pre><tt>$ git clone --reference my2.6 \
876 git://git.kernel.org/pub/scm/.../linux-
2.7 \
878 $ cd my2.7
</tt></pre>
883 Create a bare repository to publish your changes to the public:
885 <div class=
"listingblock">
886 <div class=
"content">
887 <pre><tt>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
</tt></pre>
892 Create a repository on the kernel.org machine that borrows from Linus:
894 <div class=
"listingblock">
895 <div class=
"content">
896 <pre><tt>$ git clone --bare -l -s /pub/scm/.../torvalds/linux-
2.6.git \
897 /pub/scm/.../me/subsys-
2.6.git
</tt></pre>
902 <h2 id=
"_git">GIT
</h2>
903 <div class=
"sectionbody">
904 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
907 <div id=
"footer-text">
908 Last updated
2011-
04-
02 04:
31:
58 UTC