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?
views:
199answers:
3hg 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
.
Use clone when you need to make a new repository based on another. Use pull after that to update the clone with new changesets. 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 http://www.selenic.com/hg/
then this has the exact same effect as doing
hg init hg cd hg hg pull http://www.selenic.com/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 = http://selenic.com/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 platform (Windows, Linux, Mac).
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.