RollerCosta
RollerCosta

Reputation: 5196

Difference between cloning and pulling in Mercurial

Clone and pull, these operations both are similar in functioning, so does using clone instead of pull make any sense? I mean why should I use clone if it is possible to achieve same thing by pulling an existing repo.


A team working on some application and later a new user say user2 allotted to that application by company then cloning existing repo or pulling existing repo for new entry(user2), which 1 is better? comparison b/w clone/pull

Upvotes: 2

Views: 1798

Answers (4)

Rafael Piccolo
Rafael Piccolo

Reputation: 2338

These 2 commands are completly different:

  • Clone creates a new repository
  • Pull updates an existing repository, bringing changes from another clone

First you clone a repository. After that, whenever you want to update this clone bringing the changes from another repo, you pull.

Upvotes: 1

Christian Specht
Christian Specht

Reputation: 36431

Pulling means that you already have a local repository, and you pull in just the newest changes from the remote repository that are not in your local repository yet.

But if you don't have a local repository yet, cloning creates a new one, pulls everything from the remote repository into your new local repository and updates your working copy to the newest version.
This is the easiest way to start if you join a new project - you need to get all the code once in the beginning.

You can also do the steps for cloning manually, which has the exact same effect (but just doing hg clone https://url_to_remote is easier):

  • create a new folder on local machine
  • create an empty repository in the folder (hg init)
  • pull everything from the remote repository (hg pull https://url_to_remote)
  • update your working copy (hg update)

Upvotes: 7

Sam Mackrill
Sam Mackrill

Reputation: 4061

When you clone a repository then you are making a new copy, this can be an expensive process. Also if you only use clone then you will risk losing any local changes you may have made.

  • You can think of cloning as copying a whole directory

When you pull then this just updates your repository with any changes that have been made on the parent repository, as it is just incorporating differences this will be a much more efficient process.

  • You can think of pulling as just updating the files that have changed

I recommend you go though this tutorial: http://hginit.com/

Upvotes: 0

ruturaj
ruturaj

Reputation: 3453

  • clone - is first "checkout" of the source
  • pull - is download of server's "Head" /

Upvotes: 0

Related Questions