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?
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).
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With