What is Mercurial equivalent to `git clone --depth 1`?
Feb 6, 11:59am

In Mercurial (hg), the equivalent of Git's git clone --depth 1 (which creates a shallow clone with only the most recent commit) is:

bash
hg clone --noupdate <repository-url> hg update -r tip

Explanation:

  • hg clone --noupdate: This clones the repository but does not check out any files, similar to a shallow clone in Git.
  • hg update -r tip: This updates the working directory to the latest revision (equivalent to the most recent commit in Git).

Key Differences:

  • Mercurial does not have a direct --depth option like Git. The above approach is the closest equivalent, but it still downloads the full history of the repository (just without checking out files initially).
  • If you want to avoid downloading the full history, you can use the --rev option to clone only up to a specific revision, but this is not exactly the same as Git's shallow clone.

Example:

bash
hg clone --rev tip --noupdate <repository-url> hg update -r tip

This will clone only the latest revision and update the working directory to that revision. However, Mercurial will still download the full history of the repository in the background, unlike Git's shallow clone.

Feb 6, 11:59am

This Chat is read-only. Login to resume chatting.