Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is 'pull' a synonym for 'clone' in a Mercurial source-control repository?

I'm seeing the command 'pull' and wondering how that's different from a 'clone'. Both terms seem to imply retrieving code from some remote repository. Is there some subtle distinction here?

like image 584
tent Avatar asked Sep 09 '09 05:09

tent


3 Answers

Use clone when you need to make a new repository based on another. Use pull later to transfer new changesets into the clone. You cannot use clone to fetch just the newest changesets — that is what pull is for. The pull command will compare the two repositories, find the missing changesets in your repository and finally transfer those.

However, you are right that there are similarities between clone and pull: they both transfer history between repositories. If you clone first

hg clone https://www.mercurial-scm.org/repo/hg/

then this has the exact same effect as doing

hg init hg
cd hg
hg pull https://www.mercurial-scm.org/repo/hg/
hg update

You get the exact same history in both cases. The clone command is more convenient, though, since it also edits the .hg/hgrc file for you to setup the default path:

[paths]
default = https://www.mercurial-scm.org/repo/hg/

This is what lets you do hg pull in the repository without specifying a URL. Another advantage of using clone is when you work with repositories on the same disk: hg clone a b will be very fast and cheap in terms of disk space since b will share the history with a. This is done using hardlinks and works on all platforms (Windows, Linux, Mac).

like image 86
Martin Geisler Avatar answered Nov 26 '22 21:11

Martin Geisler


hg clone is how you make a local copy of a remote repository. The Subversion equivalent is svn checkout.

hg pull pulls changes from another repository. hg update applies those changes to the local repository. hg pull -u is equivalent to hg pull; hg update. The Subversion equivalent to hg pull -u is svn update.

like image 40
las3rjock Avatar answered Nov 26 '22 21:11

las3rjock


clone creates a new repository as a copy of an existing repository.

pull imports all changesets (not already present) from another repository into an existing repository.

like image 36
wierob Avatar answered Nov 26 '22 22:11

wierob