Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between cloning and copying in Mercurial

Is copying the .hg directory to another directory the same as cloning in Mercurial (using TortoiseHg although I think that's irrelevant) or does the cloning command in Mercurial do something special during that process?

like image 330
Guy Avatar asked Apr 09 '10 03:04

Guy


People also ask

What is the difference between copying and cloning?

clone - create something new based on something that exists. copying - copy from something that exists to something else (that also already exists).

Is cloning the same as copying Git?

Cloning a repository gives you a copy of that repository and configures the original repository as a remote. Copying a repository just gives you a copy of that repository. (Though you can of course just add the remote definition afterwards via git remote add .)

How do I clone a Mercurial repository?

Clone a remote Mercurial repositoryFrom the main menu, select Hg | Get from Version Control. The Get from Version Control dialog opens. In the dialog that opens, select Mercurial from the Version control list and specify the URL of the remote repository you want to clone. Click Clone.

What is the difference between duplicate and clone command?

Clone just lets you select how many copies you want. Eg if you want to duplicate a field (or multiple fields) several times, then just select the field(s) and use clone. It will prompt for how many copies you want, then create that many in one go. Duplicate just does one duplicate of all selected fields at a time.


1 Answers

It's almost the same. Cloning does a few things different, none of which are required, but some of which are cool:

  • clones get a working directory too (which you can avoid with -U)
  • clones get the source repo set as default for push/pull in the .hg/hgrc file
  • clones can get just a subset of the original (clone -r X gets revision X and all ancestors only)
  • clones use hardlinks when the file system supports it

That last one is pretty cool. It means that if I have a 200GB repo and I do a clone -U src dest I get a full clone that uses no diskspace at all! If I skip the -U I get a working copy that takes up space, and as the two clones start to diverge the new one starts taking up space, but a basic clone -U is instantaneous and disk-space-free on modern file systems. That's not true of a copy (which does work just fine too).

like image 160
Ry4an Brase Avatar answered Oct 18 '22 05:10

Ry4an Brase