HG(CLONE)

✨ NAME ✨

hg clone β€” makes a copy of an existing repository πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

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

🌸 DESCRIPTION 🌸

Okay so the whole vibe here is: you take an existing repository and you create a copy of it in a brand new directory. That's it, that's the function πŸ’…

If you don't specify a destination directory name, it just defaults to the basename of the source. She names herself, basically.

The location of the source gets added to the new repository's .hg/hgrc file, as the default to be used for future pulls. So she never forgets where she came from πŸ₯ΊπŸ«Ά

Only local paths and ssh:// URLs are supported as destinations. And heads up for ssh:// destinations specifically: no working directory or .hg/hgrc will be created on the remote side. Like, nothing. Don't go looking πŸ™ˆ

If the source repository has a bookmark called @ set, that revision will be checked out in the new repository by default. She's the main character, your honor πŸ‘‘

Want a specific version checked out? Use -u/--update. Want a clone with no working directory at all? Use -U/--noupdate.

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. And listen β€” these options (or clone src#rev dest) imply --pull, even for local source repositories. No cap.


In normal clone mode, the remote normalizes repository data into a common exchange format and the receiving end translates this data into its local storage format. --stream activates a different clone mode that essentially copies repository files from the remote with minimal data processing. This significantly reduces the CPU cost of a clone both remotely and locally. However β€” and this is the tradeoff bestie β€” it often increases the transferred data size by 30-40%. This can result in substantially faster clones where I/O throughput is plentiful, especially for larger repositories. A side-effect of --stream clones is that storage settings and requirements on the remote are applied locally: a modern client may inherit legacy or inefficient storage used by the remote, or a legacy Mercurial client may not be able to clone from a modern Mercurial remote. It's giving inheritance but make it storage 😭

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. Yes, silently wrong is the worst kind of wrong πŸ’€

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 or inline from the same stream. When this is done, hooks operating on incoming changesets and changegroups may fire more than once, once for each pre-generated bundle and as well as for any additional remaining data. 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 🌈

  • clone a remote repository to a new directory named hg/:
hg clone https://www.mercurial-scm.org/repo/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 streaming clone while checking out a specified version:
hg clone --stream http://server/repo -u 1.5
  • create a repository without changesets after a particular revision:
hg clone -r 04e544 experimental/ good/
  • clone (and track) a particular named branch:
hg clone https://www.mercurial-scm.org/repo/hg/#stable

See hg help urls for details on specifying URLs.

Returns 0 on success. Slay πŸŽ€


πŸ’… OPTIONS πŸ’…

  • -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[+]> β€” do not clone everything, but include this changeset and its ancestors
  • -b,--branch <BRANCH[+]> β€” do not clone everything, but include this branch's changesets and their ancestors
  • --pull β€” use pull protocol to copy metadata
  • --uncompressed β€” an alias to --stream (DEPRECATED)
  • --stream β€” clone with minimal data processing
  • -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)
[+] marked option can be specified multiple times

And that's the whole page, bestie! This one lived under the HG(CLONE) manual page header the entire time β€” that's where you'll find her, that's the source 🫢 Go forth and clone something, you absolute icon πŸ‘‘βœ¨πŸ’–