Alex Rivera | Logout

Mercurial - When to use update

Asked 2010-06-23T16:27:47.290
16

When do I use update vs merge? If I do a pull from a remote repository, I'm reading that I have to do update to get those changes into my working directory. But others times I'm reading that I have to do merge.

Do I maybe want to always do an update after a pull, and then do a merge only if there are conflicts?

What am I not understanding here?

Edit
Report

1 Answer

16
  • hg update is about making your working directory the same than a given revision
  • hg merge won't reset your working directory to a given revision (it still refers the same), but will merge changes from another revision into your current working directory.

So after a pull, an hg update will change your working directory to reflect what you have pulled into your repository.
But hg merge will not reset your working directory, only merge the changes between your working directory and what you have pulled.

hg pull -u will pull and update, refusing to merge or overwrite local changes.

  • If the pull add a new HEAD in your repo, you will need to merge
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
  • If the pull add no new HEAD in your repo, a simple update is enough
answered 2010-06-23T16:35:06.630

Your Answer