| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 6 |
<meta name="generator" content="Docutils 0.21.2: https://docutils.sourceforge.io/" /> |
| 7 |
<title>hg clone</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="hg-clone"> |
| 12 |
<span id="hg-clone-1"></span> |
| 13 |
<h1 class="title">hg clone</h1> |
| 14 |
<h2 class="subtitle" id="make-a-copy-of-an-existing-repository">make a copy of an existing repository</h2> |
| 15 |
|
| 16 |
<div class="contents htmlonly topic" id="contents"> |
| 17 |
<p class="topic-title"><a class="reference internal" href="#top">Contents</a></p> |
| 18 |
<ul class="simple"> |
| 19 |
<li><a class="reference internal" href="#synopsis" id="toc-entry-1">Synopsis</a></li> |
| 20 |
<li><a class="reference internal" href="#description" id="toc-entry-2">Description</a></li> |
| 21 |
<li><a class="reference internal" href="#options" id="toc-entry-3">Options</a></li> |
| 22 |
</ul> |
| 23 |
</div> |
| 24 |
<div class="section" id="synopsis"> |
| 25 |
<h1><a class="toc-backref" href="#contents">Synopsis</a></h1> |
| 26 |
<pre class="literal-block"> |
| 27 |
hg clone [OPTION]... SOURCE [DEST] |
| 28 |
</pre> |
| 29 |
</div> |
| 30 |
<div class="section" id="description"> |
| 31 |
<h1><a class="toc-backref" href="#contents">Description</a></h1> |
| 32 |
<p>Create a copy of an existing repository in a new directory.</p> |
| 33 |
<p>If no destination directory name is specified, it defaults to the |
| 34 |
basename of the source.</p> |
| 35 |
<p>The location of the source is added to the new repository's |
| 36 |
<tt class="docutils literal">.hg/hgrc</tt> file, as the default to be used for future pulls.</p> |
| 37 |
<p>Only local paths and <tt class="docutils literal"><span class="pre">ssh://</span></tt> URLs are supported as |
| 38 |
destinations. For <tt class="docutils literal"><span class="pre">ssh://</span></tt> destinations, no working directory or |
| 39 |
<tt class="docutils literal">.hg/hgrc</tt> will be created on the remote side.</p> |
| 40 |
<p>If the source repository has a bookmark called '@' set, that |
| 41 |
revision will be checked out in the new repository by default.</p> |
| 42 |
<p>To check out a particular version, use -u/--update, or |
| 43 |
-U/--noupdate to create a clone with no working directory.</p> |
| 44 |
<p>To pull only a subset of changesets, specify one or more revisions |
| 45 |
identifiers with -r/--rev or branches with -b/--branch. The |
| 46 |
resulting clone will contain only the specified changesets and |
| 47 |
their ancestors. These options (or 'clone src#rev dest') imply |
| 48 |
--pull, even for local source repositories.</p> |
| 49 |
<p>In normal clone mode, the remote normalizes repository data into a common |
| 50 |
exchange format and the receiving end translates this data into its local |
| 51 |
storage format. --stream activates a different clone mode that essentially |
| 52 |
copies repository files from the remote with minimal data processing. This |
| 53 |
significantly reduces the CPU cost of a clone both remotely and locally. |
| 54 |
However, it often increases the transferred data size by 30-40%. This can |
| 55 |
result in substantially faster clones where I/O throughput is plentiful, |
| 56 |
especially for larger repositories. A side-effect of --stream clones is |
| 57 |
that storage settings and requirements on the remote are applied locally: |
| 58 |
a modern client may inherit legacy or inefficient storage used by the |
| 59 |
remote or a legacy Mercurial client may not be able to clone from a |
| 60 |
modern Mercurial remote.</p> |
| 61 |
<div class="admonition note"> |
| 62 |
<p class="first admonition-title">Note</p> |
| 63 |
<p class="last">Specifying a tag will include the tagged changeset but not the |
| 64 |
changeset containing the tag.</p> |
| 65 |
</div> |
| 66 |
<div class="verbose docutils container"> |
| 67 |
<p>For efficiency, hardlinks are used for cloning whenever the |
| 68 |
source and destination are on the same filesystem (note this |
| 69 |
applies only to the repository data, not to the working |
| 70 |
directory). Some filesystems, such as AFS, implement hardlinking |
| 71 |
incorrectly, but do not report errors. In these cases, use the |
| 72 |
--pull option to avoid hardlinking.</p> |
| 73 |
<p>Mercurial will update the working directory to the first applicable |
| 74 |
revision from this list:</p> |
| 75 |
<ol class="loweralpha simple"> |
| 76 |
<li>null if -U or the source repository has no changesets</li> |
| 77 |
<li>if -u . and the source repository is local, the first parent of |
| 78 |
the source repository's working directory</li> |
| 79 |
<li>the changeset specified with -u (if a branch name, this means the |
| 80 |
latest head of that branch)</li> |
| 81 |
<li>the changeset specified with -r</li> |
| 82 |
<li>the tipmost head specified with -b</li> |
| 83 |
<li>the tipmost head specified with the url#branch source syntax</li> |
| 84 |
<li>the revision marked with the '@' bookmark, if present</li> |
| 85 |
<li>the tipmost head of the default branch</li> |
| 86 |
<li>tip</li> |
| 87 |
</ol> |
| 88 |
<p>When cloning from servers that support it, Mercurial may fetch |
| 89 |
pre-generated data from a server-advertised URL or inline from the |
| 90 |
same stream. When this is done, hooks operating on incoming changesets |
| 91 |
and changegroups may fire more than once, once for each pre-generated |
| 92 |
bundle and as well as for any additional remaining data. In addition, |
| 93 |
if an error occurs, the repository may be rolled back to a partial |
| 94 |
clone. This behavior may change in future releases. |
| 95 |
See <a class="reference external" href="hg.1.html#-e"><tt class="docutils literal">hg help <span class="pre">-e</span> clonebundles</tt></a> for more.</p> |
| 96 |
<p>Examples:</p> |
| 97 |
<ul> |
| 98 |
<li><p class="first">clone a remote repository to a new directory named hg/:</p> |
| 99 |
<pre class="literal-block"> |
| 100 |
hg clone https://www.mercurial-scm.org/repo/hg/ |
| 101 |
</pre> |
| 102 |
</li> |
| 103 |
<li><p class="first">create a lightweight local clone:</p> |
| 104 |
<pre class="literal-block"> |
| 105 |
hg clone project/ project-feature/ |
| 106 |
</pre> |
| 107 |
</li> |
| 108 |
<li><p class="first">clone from an absolute path on an ssh server (note double-slash):</p> |
| 109 |
<pre class="literal-block"> |
| 110 |
hg clone ssh://user@server//home/projects/alpha/ |
| 111 |
</pre> |
| 112 |
</li> |
| 113 |
<li><p class="first">do a streaming clone while checking out a specified version:</p> |
| 114 |
<pre class="literal-block"> |
| 115 |
hg clone --stream http://server/repo -u 1.5 |
| 116 |
</pre> |
| 117 |
</li> |
| 118 |
<li><p class="first">create a repository without changesets after a particular revision:</p> |
| 119 |
<pre class="literal-block"> |
| 120 |
hg clone -r 04e544 experimental/ good/ |
| 121 |
</pre> |
| 122 |
</li> |
| 123 |
<li><p class="first">clone (and track) a particular named branch:</p> |
| 124 |
<pre class="literal-block"> |
| 125 |
hg clone https://www.mercurial-scm.org/repo/hg/#stable |
| 126 |
</pre> |
| 127 |
</li> |
| 128 |
</ul> |
| 129 |
</div> |
| 130 |
<p>See <a class="reference external" href="topic-urls.html"><tt class="docutils literal">hg help urls</tt></a> for details on specifying URLs.</p> |
| 131 |
<p>Returns 0 on success.</p> |
| 132 |
</div> |
| 133 |
<div class="section" id="options"> |
| 134 |
<h1><a class="toc-backref" href="#contents">Options</a></h1> |
| 135 |
<table class="docutils option-list" frame="void" rules="none"> |
| 136 |
<col class="option" /> |
| 137 |
<col class="description" /> |
| 138 |
<tbody valign="top"> |
| 139 |
<tr><td class="option-group"> |
| 140 |
<kbd><span class="option">-U</span>, <span class="option">--noupdate</span></kbd></td> |
| 141 |
<td>the clone will include an empty working directory (only a repository)</td></tr> |
| 142 |
<tr><td class="option-group" colspan="2"> |
| 143 |
<kbd><span class="option">-u</span>, <span class="option">--updaterev <var><REV></var></span></kbd></td> |
| 144 |
</tr> |
| 145 |
<tr><td> </td><td>revision, tag, or branch to check out</td></tr> |
| 146 |
<tr><td class="option-group" colspan="2"> |
| 147 |
<kbd><span class="option">-r</span>, <span class="option">--rev <var><REV[+]></var></span></kbd></td> |
| 148 |
</tr> |
| 149 |
<tr><td> </td><td>do not clone everything, but include this changeset and its ancestors</td></tr> |
| 150 |
<tr><td class="option-group" colspan="2"> |
| 151 |
<kbd><span class="option">-b</span>, <span class="option">--branch <var><BRANCH[+]></var></span></kbd></td> |
| 152 |
</tr> |
| 153 |
<tr><td> </td><td>do not clone everything, but include this branch's changesets and their ancestors</td></tr> |
| 154 |
<tr><td class="option-group"> |
| 155 |
<kbd><span class="option">--pull</span></kbd></td> |
| 156 |
<td>use pull protocol to copy metadata</td></tr> |
| 157 |
<tr><td class="option-group"> |
| 158 |
<kbd><span class="option">--uncompressed</span></kbd></td> |
| 159 |
<td>an alias to --stream (DEPRECATED)</td></tr> |
| 160 |
<tr><td class="option-group"> |
| 161 |
<kbd><span class="option">--stream</span></kbd></td> |
| 162 |
<td>clone with minimal data processing</td></tr> |
| 163 |
<tr><td class="option-group" colspan="2"> |
| 164 |
<kbd><span class="option">-e</span>, <span class="option">--ssh <var><CMD></var></span></kbd></td> |
| 165 |
</tr> |
| 166 |
<tr><td> </td><td>specify ssh command to use</td></tr> |
| 167 |
<tr><td class="option-group" colspan="2"> |
| 168 |
<kbd><span class="option">--remotecmd <var><CMD></var></span></kbd></td> |
| 169 |
</tr> |
| 170 |
<tr><td> </td><td>specify hg command to run on the remote side</td></tr> |
| 171 |
<tr><td class="option-group"> |
| 172 |
<kbd><span class="option">--insecure</span></kbd></td> |
| 173 |
<td>do not verify server certificate (ignoring web.cacerts config)</td></tr> |
| 174 |
</tbody> |
| 175 |
</table> |
| 176 |
<p>[+] marked option can be specified multiple times</p> |
| 177 |
</div> |
| 178 |
</div> |
| 179 |
</body> |
| 180 |
</html> |