Help: clone

Find changesets by keywords (author, files, the commit message), revision
number or hash, or revset expression.

hg clone [OPTION]... SOURCE [DEST]

make a copy of an existing repository

Create a copy of an existing repository in a new directory.

If no destination directory name is specified, it defaults to the
basename of the source.

The location of the source is added to the new repository's
".hg/hgrc" file, as the default to be used for future pulls.

Only local paths and "ssh://" URLs are supported as
destinations. For "ssh://" destinations, no working directory or
".hg/hgrc" will be created on the remote side.

To pull only a subset of changesets, specify one or more revisions
identifiers with -r/--rev or branches with -b/--branch. The
resulting clone will contain only the specified changesets and
their ancestors. These options (or 'clone src#rev dest') imply
--pull, even for local source repositories. Note that specifying a
tag will include the tagged changeset but not the changeset
containing the tag.

If the source repository has a bookmark called '@' set, that
revision will be checked out in the new repository by default.

To check out a particular version, use -u/--update, or
-U/--noupdate to create a clone with no working directory.

For efficiency, hardlinks are used for cloning whenever the
source and destination are on the same filesystem (note this
applies only to the repository data, not to the working
directory). Some filesystems, such as AFS, implement hardlinking
incorrectly, but do not report errors. In these cases, use the
--pull option to avoid hardlinking.

In some cases, you can clone repositories and the working
directory using full hardlinks with

$ cp -al REPO REPOCLONE

This is the fastest way to clone, but it is not always safe. The
operation is not atomic (making sure REPO is not modified during
the operation is up to you) and you have to make sure your
editor breaks hardlinks (Emacs and most Linux Kernel tools do
so). Also, this is not compatible with certain extensions that
place their metadata under the .hg directory, such as mq.

Mercurial will update the working directory to the first applicable
revision from this list:

null if -U or the source repository has no changesets

if -u . and the source repository is local, the first parent of the source repository's working directory

the changeset specified with -u (if a branch name, this means the latest head of that branch)

the changeset specified with -r

the tipmost head specified with -b

the tipmost head specified with the url#branch source syntax

the revision marked with the '@' bookmark, if present

the tipmost head of the default branch

tip

Examples:

clone a remote repository to a new directory named hg/:

hg clone http://selenic.com/hg

create a lightweight local clone:

hg clone project/ project-feature/

clone from an absolute path on an ssh server (note double-slash):

hg clone ssh://user@server//home/projects/alpha/

do a high-speed clone over a LAN while checking out a specified version: