blob: e85e4d65bc94af1203a74e35fe375fc6794bfe0b [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 8.2.5" />
<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;
text-decoration: underline;
}
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, h2, h3 {
border-bottom: 2px solid silver;
}
h2 {
padding-top: 0.5em;
}
h3 {
float: left;
}
h3 + * {
clear: left;
}
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.1em;
}
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 {
margin-right: 0%;
}
div.listingblock > div.content {
border: 1px solid silver;
background: #f4f4f4;
padding: 0.5em;
}
div.quoteblock > div.content {
padding-left: 2.0em;
}
div.attribution {
text-align: right;
}
div.verseblock + div.attribution {
text-align: left;
}
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;
}
div.olist2 ol {
list-style-type: lower-alpha;
}
div.tableblock > table {
border: 3px solid #527bbd;
}
thead {
font-family: sans-serif;
font-weight: bold;
}
tfoot {
font-weight: bold;
}
div.hlist {
margin-top: 0.8em;
margin-bottom: 0.8em;
}
div.hlist td {
padding-bottom: 5px;
}
td.hlist1 {
vertical-align: top;
font-style: italic;
padding-right: 0.8em;
}
td.hlist2 {
vertical-align: top;
}
@media print {
div#footer-badges { display: none; }
}
div#toctitle {
color: #527bbd;
font-family: sans-serif;
font-size: 1.1em;
font-weight: bold;
margin-top: 1.0em;
margin-bottom: 0.1em;
}
div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
margin-top: 0;
margin-bottom: 0;
}
div.toclevel2 {
margin-left: 2em;
font-size: 0.9em;
}
div.toclevel3 {
margin-left: 4em;
font-size: 0.9em;
}
div.toclevel4 {
margin-left: 6em;
font-size: 0.9em;
}
include1::./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;
}
/* IE6 sets dynamically generated links as visited. */
div#toc a:visited { color: blue; }
</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] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
[-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 id="_description">DESCRIPTION</h2>
<div class="sectionbody">
<div class="para"><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></div>
<div class="para"><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></div>
<div class="para"><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>
</div>
<h2 id="_options">OPTIONS</h2>
<div class="sectionbody">
<div class="vlist"><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 <tt>.git/objects/</tt> directory are hardlinked
to save space when possible. This is now the default when
the source repository is specified with <tt>/path/to/repo</tt>
syntax, so it essentially is a no-op option. To force
copying instead of hardlinking (which may be desirable
if you are trying to make a back-up of your repository),
but still avoid the usual "git aware" transport
mechanism, <tt>--no-hardlinks</tt> can be used.
</p>
</dd>
<dt>
--no-hardlinks
</dt>
<dd>
<p>
Optimize the cloning process from a repository on a
local filesystem by copying files under <tt>.git/objects</tt>
directory.
</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>
<div class="para"><p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use
it unless you understand what it does. If you clone your
repository using this option and then delete branches (or use any
other git command that makes any existing commit unreferenced) in the
source repository, some objects may become unreferenced (or dangling).
These objects may be removed by normal git operations (such as <em>git-commit</em>)
which automatically call <tt>git gc --auto</tt>. (See <a href="git-gc.html">git-gc(1)</a>.)
If these objects are removed and were referenced by the cloned repository,
then the cloned repository will become corrupt.</p></div>
</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 fewer objects to be copied from the repository
being cloned, reducing network and local storage costs.
</p>
<div class="para"><p><strong>NOTE</strong>: see NOTE to --shared option.</p></div>
</dd>
<dt>
--quiet
</dt>
<dt>
-q
</dt>
<dd>
<p>
Operate quietly. This flag is also passed to the `rsync'
command when given.
</p>
</dd>
<dt>
--verbose
</dt>
<dt>
-v
</dt>
<dd>
<p>
Display the progressbar, even in case the standard output is not
a terminal.
</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>
--mirror
</dt>
<dd>
<p>
Set up a mirror of the remote repository. This implies --bare.
</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;.
</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 accessed
via ssh, this specifies a 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 revisions. A shallow repository has a
number of limitations (you cannot clone or fetch from
it, nor push from nor into it), but is adequate if you
are only interested in the recent history of a large project
with a long history, and would want to send in 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 only allowed if the directory is empty.
</p>
</dd>
</dl></div>
</div>
<h2 id="_git_urls_a_id_urls_a">GIT URLS<a id="URLS"></a></h2>
<div class="sectionbody">
<div class="para"><p>One of the following notations can be used
to name the remote repository:</p></div>
<div class="exampleblock">
<div class="exampleblock-content">
<div class="ilist"><ul>
<li>
<p>
rsync://host.xz/path/to/repo.git/
</p>
</li>
<li>
<p>
http://host.xz&#91;:port&#93;/path/to/repo.git/
</p>
</li>
<li>
<p>
https://host.xz&#91;:port&#93;/path/to/repo.git/
</p>
</li>
<li>
<p>
git://host.xz&#91;:port&#93;/path/to/repo.git/
</p>
</li>
<li>
<p>
git://host.xz&#91;:port&#93;/~user/path/to/repo.git/
</p>
</li>
<li>
<p>
ssh://&#91;user@&#93;host.xz&#91;:port&#93;/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></div>
<div class="para"><p>SSH is the default transport protocol over the network. 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, but
only the former supports port specification. The following
three are identical to the last three above, respectively:</p></div>
<div class="exampleblock">
<div class="exampleblock-content">
<div class="ilist"><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></div>
<div class="para"><p>To sync with a local directory, you can use:</p></div>
<div class="exampleblock">
<div class="exampleblock-content">
<div class="ilist"><ul>
<li>
<p>
/path/to/repo.git/
</p>
</li>
<li>
<p>
file:///path/to/repo.git/
</p>
</li>
</ul></div>
</div></div>
<div class="para"><p>They are equivalent, except the former implies --local option.</p></div>
<div class="para"><p>If there are a large number of similarly-named remote repositories and
you want to use a different format for them (such that the URLs you
use will be rewritten into URLs that work), you can create a
configuration section of the form:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt> [url "&lt;actual url base&gt;"]
insteadOf = &lt;other url base&gt;</tt></pre>
</div></div>
<div class="para"><p>For example, with this:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt> [url "git://git.host.xz/"]
insteadOf = host.xz:/path/to/
insteadOf = work:</tt></pre>
</div></div>
<div class="para"><p>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</p></div>
</div>
<h2 id="_examples">Examples</h2>
<div class="sectionbody">
<div class="vlist"><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>
</div>
<h2 id="_author">Author</h2>
<div class="sectionbody">
<div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
</div>
<h2 id="_documentation">Documentation</h2>
<div class="sectionbody">
<div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
</div>
<h2 id="_git">GIT</h2>
<div class="sectionbody">
<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2009-07-01 02:30:45 UTC
</div>
</div>
</body>
</html>