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.

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.

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:

Specifying a tag will include the tagged changeset but not the changeset containing the tag.

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:

  1. null if -U or the source repository has no changesets
  2. if -u . and the source repository is local, the first parent of the source repository's working directory
  3. the changeset specified with -u (if a branch name, this means the latest head of that branch)
  4. the changeset specified with -r
  5. the tipmost head specified with -b
  6. the tipmost head specified with the url#branch source syntax
  7. the revision marked with the '@' bookmark, if present
  8. the tipmost head of the default branch
  9. tip

When cloning from servers that support it, Mercurial may fetch pre-generated data from a server-advertised URL. When this is done, hooks operating on incoming changesets and changegroups may fire twice, once for the bundle fetched from the URL and another for any additional data not fetched from this URL. In addition, if an error occurs, the repository may be rolled back to a partial clone. This behavior may change in future releases. See 'hg help -e clonebundles' for more.

Examples:

See 'hg help urls' for details on specifying URLs.

Returns 0 on success.

options ([+] can be repeated):

-U --noupdate the clone will include an empty working directory (only a repository)
-u --updaterev REV revision, tag, or branch to check out
-r --rev REV [+] include the specified changeset
-b --branch BRANCH [+] clone only the specified branch
--pull use pull protocol to copy metadata
--uncompressed use uncompressed transfer (fast over LAN)
-e --ssh CMD specify ssh command to use
--remotecmd CMD specify hg command to run on the remote side
--insecure do not verify server certificate (ignoring web.cacerts config)

global options ([+] can be repeated):

-R --repository REPO repository root directory or name of overlay bundle file
--cwd DIR change working directory
-y --noninteractive do not prompt, automatically pick the first choice for all prompts
-q --quiet suppress output
-v --verbose enable additional output
--color TYPE when to colorize (boolean, always, auto, never, or debug)
--config CONFIG [+] set/override config option (use 'section.name=value')
--debug enable debugging output
--debugger start debugger
--encoding ENCODE set the charset encoding (default: ISO-8859-1)
--encodingmode MODE set the charset encoding mode (default: strict)
--traceback always print a traceback on exception
--time time how long the command takes
--profile print command execution profile
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
--pager TYPE when to paginate (boolean, always, auto, or never) (default: auto)

mercurial