What's the difference between update and pull?

28,995

Solution 1

hg update : http://www.selenic.com/mercurial/hg.1.html#update

  • Update the repository's working directory (the "working copy") to the specified revision of the repository

hg pull : http://www.selenic.com/mercurial/hg.1.html#pull

  • Allows you to bring changes from a remote repository

So when you do an hg pull, you bring changes to your repository which is under .hg. It will not reflect in your working directory.

After that, when you do a hg update, the changes are brought to your working copy.

Your repo                                 Remote Repo
 \                                        \
  |                hg pull                 |
  |-.hg  <-------------------------------- |-.hg
  |   |  --------------------------------> |
  |  hg update       hg push               |
  |   |                                    |
  |- working folder                        |- working folder

This is very usual confusion when coming from subversion like version control systems.

In subversion : svn update bring the changes from central repo server to your working copy

But in DVCSs , you have both a local repository and working copy. So update does exactly the same but pulls the changes from your local repo to local working copy.

Solution 2

Mercurial is a distributed revision control system, so you have the whole repo history as well as your version of the code (called the "working copy").

pull brings in remote changes to your local repo.

update changes your working copy to match the newest version in your local repo.

So if you clone a remote branch and keep running update, your code won't change because you're never downloading remote code. If you keep running pull, then your code won't change because you're never using the remote code (applying it to your working version of the code).

Solution 3

This picture from this link can help to understand it:

How Mercurial does it

Share:
28,995
emurad
Author by

emurad

Updated on March 18, 2020

Comments

  • emurad
    emurad over 4 years

    Can someone clarify what's the exact difference between update and pull commands?

    Thanks.

  • colidyre
    colidyre over 4 years
    Including some textual context to the provided picture could help to better understand your answer. I'm not downvoted, though
  • Allan
    Allan about 2 years
    No words for this pic :). Thanks