blob: a35e341596a8977f701ea09b80ad8511e885e81b [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="AsciiDoc 7.0.2" />
<style type="text/css">
/* Debug borders */
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
/*
border: 1px solid red;
*/
}
body {
margin: 1em 5% 1em 5%;
}
a { color: blue; }
a:visited { color: fuchsia; }
em {
font-style: italic;
}
strong {
font-weight: bold;
}
tt {
color: navy;
}
h1, h2, h3, h4, h5, h6 {
color: #527bbd;
font-family: sans-serif;
margin-top: 1.2em;
margin-bottom: 0.5em;
line-height: 1.3;
}
h1 {
border-bottom: 2px solid silver;
}
h2 {
border-bottom: 2px solid silver;
padding-top: 0.5em;
}
div.sectionbody {
font-family: serif;
margin-left: 0;
}
hr {
border: 1px solid silver;
}
p {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
pre {
padding: 0;
margin: 0;
}
span#author {
color: #527bbd;
font-family: sans-serif;
font-weight: bold;
font-size: 1.2em;
}
span#email {
}
span#revision {
font-family: sans-serif;
}
div#footer {
font-family: sans-serif;
font-size: small;
border-top: 2px solid silver;
padding-top: 0.5em;
margin-top: 4.0em;
}
div#footer-text {
float: left;
padding-bottom: 0.5em;
}
div#footer-badges {
float: right;
padding-bottom: 0.5em;
}
div#preamble,
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
margin-right: 10%;
margin-top: 1.5em;
margin-bottom: 1.5em;
}
div.admonitionblock {
margin-top: 2.5em;
margin-bottom: 2.5em;
}
div.content { /* Block element content. */
padding: 0;
}
/* Block element titles. */
div.title, caption.title {
font-family: sans-serif;
font-weight: bold;
text-align: left;
margin-top: 1.0em;
margin-bottom: 0.5em;
}
div.title + * {
margin-top: 0;
}
td div.title:first-child {
margin-top: 0.0em;
}
div.content div.title:first-child {
margin-top: 0.0em;
}
div.content + div.title {
margin-top: 0.0em;
}
div.sidebarblock > div.content {
background: #ffffee;
border: 1px solid silver;
padding: 0.5em;
}
div.listingblock > div.content {
border: 1px solid silver;
background: #f4f4f4;
padding: 0.5em;
}
div.quoteblock > div.content {
padding-left: 2.0em;
}
div.quoteblock .attribution {
text-align: right;
}
div.admonitionblock .icon {
vertical-align: top;
font-size: 1.1em;
font-weight: bold;
text-decoration: underline;
color: #527bbd;
padding-right: 0.5em;
}
div.admonitionblock td.content {
padding-left: 0.5em;
border-left: 2px solid silver;
}
div.exampleblock > div.content {
border-left: 2px solid silver;
padding: 0.5em;
}
div.verseblock div.content {
white-space: pre;
}
div.imageblock div.content { padding-left: 0; }
div.imageblock img { border: 1px solid silver; }
span.image img { border-style: none; }
dl {
margin-top: 0.8em;
margin-bottom: 0.8em;
}
dt {
margin-top: 0.5em;
margin-bottom: 0;
font-style: italic;
}
dd > *:first-child {
margin-top: 0;
}
ul, ol {
list-style-position: outside;
}
ol.olist2 {
list-style-type: lower-alpha;
}
div.tableblock > table {
border-color: #527bbd;
border-width: 3px;
}
thead {
font-family: sans-serif;
font-weight: bold;
}
tfoot {
font-weight: bold;
}
div.hlist {
margin-top: 0.8em;
margin-bottom: 0.8em;
}
td.hlist1 {
vertical-align: top;
font-style: italic;
padding-right: 0.8em;
}
td.hlist2 {
vertical-align: top;
}
@media print {
div#footer-badges { display: none; }
}
include::./stylesheets/xhtml11-manpage.css[]
/* Workarounds for IE6's broken and incomplete CSS2. */
div.sidebar-content {
background: #ffffee;
border: 1px solid silver;
padding: 0.5em;
}
div.sidebar-title, div.image-title {
font-family: sans-serif;
font-weight: bold;
margin-top: 0.0em;
margin-bottom: 0.5em;
}
div.listingblock div.content {
border: 1px solid silver;
background: #f4f4f4;
padding: 0.5em;
}
div.quoteblock-content {
padding-left: 2.0em;
}
div.exampleblock-content {
border-left: 2px solid silver;
padding-left: 0.5em;
}
</style>
<title>git-clone(1)</title>
</head>
<body>
<div id="header">
<h1>
git-clone(1) Manual Page
</h1>
<h2>NAME</h2>
<div class="sectionbody">
<p>git-clone -
Clone a repository into a new directory
</p>
</div>
</div>
<h2>SYNOPSIS</h2>
<div class="sectionbody">
<div class="verseblock">
<div class="content"><em>git-clone</em> [--template=&lt;template_directory&gt;] [-l [-s]] [-q] [-n] [--bare]
[-o &lt;name&gt;] [-u &lt;upload-pack&gt;] [--reference &lt;repository&gt;]
[--depth &lt;depth&gt;] &lt;repository&gt; [&lt;directory&gt;]</div></div>
</div>
<h2>DESCRIPTION</h2>
<div class="sectionbody">
<p>Clones a repository into a newly created directory, creates
remote-tracking branches for each branch in the cloned repository
(visible using <tt>git branch -r</tt>), and creates and checks out an initial
branch equal to the cloned repository's currently active branch.</p>
<p>After the clone, a plain <tt>git fetch</tt> without arguments will update
all the remote-tracking branches, and a <tt>git pull</tt> without
arguments will in addition merge the remote master branch into the
current master branch, if any.</p>
<p>This default configuration is achieved by creating references to
the remote branch heads under <tt>$GIT_DIR/refs/remotes/origin</tt> and
by initializing <tt>remote.origin.url</tt> and <tt>remote.origin.fetch</tt>
configuration variables.</p>
</div>
<h2>OPTIONS</h2>
<div class="sectionbody">
<dl>
<dt>
--local
</dt>
<dt>
-l
</dt>
<dd>
<p>
When the repository to clone from is on a local machine,
this flag bypasses normal "git aware" transport
mechanism and clones the repository by making a copy of
HEAD and everything under objects and refs directories.
The files under .git/objects/ directory are hardlinked
to save space when possible.
</p>
</dd>
<dt>
--shared
</dt>
<dt>
-s
</dt>
<dd>
<p>
When the repository to clone is on the local machine,
instead of using hard links, automatically setup
.git/objects/info/alternates to share the objects
with the source repository. The resulting repository
starts out without any object of its own.
</p>
</dd>
<dt>
--reference &lt;repository&gt;
</dt>
<dd>
<p>
If the reference repository is on the local machine
automatically setup .git/objects/info/alternates to
obtain objects from the reference repository. Using
an already existing repository as an alternate will
require less objects to be copied from the repository
being cloned, reducing network and local storage costs.
</p>
</dd>
<dt>
--quiet
</dt>
<dt>
-q
</dt>
<dd>
<p>
Operate quietly. This flag is passed to "rsync" and
"git-fetch-pack" commands when given.
</p>
</dd>
<dt>
--no-checkout
</dt>
<dt>
-n
</dt>
<dd>
<p>
No checkout of HEAD is performed after the clone is complete.
</p>
</dd>
<dt>
--bare
</dt>
<dd>
<p>
Make a <em>bare</em> GIT repository. That is, instead of
creating <tt>&lt;directory&gt;</tt> and placing the administrative
files in <tt>&lt;directory&gt;/.git</tt>, make the <tt>&lt;directory&gt;</tt>
itself the <tt>$GIT_DIR</tt>. This obviously implies the <tt>-n</tt>
because there is nowhere to check out the working tree.
Also the branch heads at the remote are copied directly
to corresponding local branch heads, without mapping
them to <tt>refs/remotes/origin/</tt>. When this option is
used, neither remote-tracking branches nor the related
configuration variables are created.
</p>
</dd>
<dt>
--origin &lt;name&gt;
</dt>
<dt>
-o &lt;name&gt;
</dt>
<dd>
<p>
Instead of using the remote name <em>origin</em> to keep track
of the upstream repository, use &lt;name&gt; instead.
</p>
</dd>
<dt>
--upload-pack &lt;upload-pack&gt;
</dt>
<dt>
-u &lt;upload-pack&gt;
</dt>
<dd>
<p>
When given, and the repository to clone from is handled
by <em>git-fetch-pack</em>, <em>--exec=&lt;upload-pack&gt;</em> is passed to
the command to specify non-default path for the command
run on the other end.
</p>
</dd>
<dt>
--template=&lt;template_directory&gt;
</dt>
<dd>
<p>
Specify the directory from which templates will be used;
if unset the templates are taken from the installation
defined default, typically <tt>/usr/share/git-core/templates</tt>.
</p>
</dd>
<dt>
--depth &lt;depth&gt;
</dt>
<dd>
<p>
Create a <em>shallow</em> clone with a history truncated to the
specified number of revs. A shallow repository has
number of limitations (you cannot clone or fetch from
it, nor push from nor into it), but is adequate if you
want to only look at near the tip of a large project
with a long history, and would want to send in a fixes
as patches.
</p>
</dd>
<dt>
&lt;repository&gt;
</dt>
<dd>
<p>
The (possibly remote) repository to clone from. See the
<a href="#URLS">URLS</a> section below for more information on specifying
repositories.
</p>
</dd>
<dt>
&lt;directory&gt;
</dt>
<dd>
<p>
The name of a new directory to clone into. The "humanish"
part of the source repository is used if no directory is
explicitly given ("repo" for "/path/to/repo.git" and "foo"
for "host.xz:foo/.git"). Cloning into an existing directory
is not allowed.
</p>
</dd>
</dl>
</div>
<h2>GIT URLS<a id="URLS"></a></h2>
<div class="sectionbody">
<p>One of the following notations can be used
to name the remote repository:</p>
<div class="exampleblock">
<div class="exampleblock-content">
<ul>
<li>
<p>
rsync://host.xz/path/to/repo.git/
</p>
</li>
<li>
<p>
http://host.xz/path/to/repo.git/
</p>
</li>
<li>
<p>
https://host.xz/path/to/repo.git/
</p>
</li>
<li>
<p>
git://host.xz/path/to/repo.git/
</p>
</li>
<li>
<p>
git://host.xz/~user/path/to/repo.git/
</p>
</li>
<li>
<p>
ssh://&#91;user@&#93;host.xz/path/to/repo.git/
</p>
</li>
<li>
<p>
ssh://&#91;user@&#93;host.xz/~user/path/to/repo.git/
</p>
</li>
<li>
<p>
ssh://&#91;user@&#93;host.xz/~/path/to/repo.git
</p>
</li>
</ul>
</div></div>
<p>SSH is the default transport protocol. You can optionally specify
which user to log-in as, and an alternate, scp-like syntax is also
supported. Both syntaxes support username expansion,
as does the native git protocol. The following three are
identical to the last three above, respectively:</p>
<div class="exampleblock">
<div class="exampleblock-content">
<ul>
<li>
<p>
&#91;user@&#93;host.xz:/path/to/repo.git/
</p>
</li>
<li>
<p>
&#91;user@&#93;host.xz:~user/path/to/repo.git/
</p>
</li>
<li>
<p>
&#91;user@&#93;host.xz:path/to/repo.git
</p>
</li>
</ul>
</div></div>
<p>To sync with a local directory, use:</p>
<div class="exampleblock">
<div class="exampleblock-content">
<ul>
<li>
<p>
/path/to/repo.git/
</p>
</li>
</ul>
</div></div>
</div>
<h2>Examples</h2>
<div class="sectionbody">
<dl>
<dt>
Clone from upstream
</dt>
<dd>
<div class="listingblock">
<div class="content">
<pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
$ cd my2.6
$ make</tt></pre>
</div></div>
</dd>
<dt>
Make a local clone that borrows from the current directory, without checking things out
</dt>
<dd>
<div class="listingblock">
<div class="content">
<pre><tt>$ git clone -l -s -n . ../copy
$ cd ../copy
$ git show-branch</tt></pre>
</div></div>
</dd>
<dt>
Clone from upstream while borrowing from an existing local directory
</dt>
<dd>
<div class="listingblock">
<div class="content">
<pre><tt>$ git clone --reference my2.6 \
git://git.kernel.org/pub/scm/.../linux-2.7 \
my2.7
$ cd my2.7</tt></pre>
</div></div>
</dd>
<dt>
Create a bare repository to publish your changes to the public
</dt>
<dd>
<div class="listingblock">
<div class="content">
<pre><tt>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git</tt></pre>
</div></div>
</dd>
<dt>
Create a repository on the kernel.org machine that borrows from Linus
</dt>
<dd>
<div class="listingblock">
<div class="content">
<pre><tt>$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
/pub/scm/.../me/subsys-2.6.git</tt></pre>
</div></div>
</dd>
</dl>
</div>
<h2>Author</h2>
<div class="sectionbody">
<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
</div>
<h2>Documentation</h2>
<div class="sectionbody">
<p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
</div>
<h2>GIT</h2>
<div class="sectionbody">
<p>Part of the <a href="git.html">git(7)</a> suite</p>
</div>
<div id="footer">
<div id="footer-text">
Last updated 19-Jul-2007 02:09:34 UTC
</div>
</div>
</body>
</html>