views:

62

answers:

2

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?

+2  A: 
  • 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
VonC
+2  A: 

If you have local commits: merge. If you have uncommitted local modifications: update (which will merge).

Usually when you make a commit locally, it forks the tree when you pull. In this case you always have to merge (or rebase with the rebase extension). If you have uncommitted local modifications, then when you pull, you can update and merge the changes into your workspace.

ataylor