Mercurial branching and bookmarks
Bookmarks are tags that move forward automatically to subsequent changes, leaving no mark on the changesets that previously had that bookmark pointing toward them. Named branches, on the other hand, are indelible marks that are part of a changeset. Multiple heads can be on the same branch, but only one head at a time can be pointed to by the same bookmark. Named branches are pushed/pulled from repo to repo, and bookmarks don't travel.
There's a great branching comparison here: http://stevelosh.com/blog/entry/2009/8/30/a-guide-to-branching-in-mercurial/
viraptor
Dev-ops monkey interested in clouds Using: C / python / many exotic languages
Updated on August 05, 2022Comments
-
viraptor almost 2 years
I read some information about named branches and working with bookmarks. Unfortunately I still don't see a difference between them. Is there any?
Is there any difference between:
hg branch blah hg up blah
and
hg bookmark blah hg up blah
?
Why would I use a bookmark and how is it different from a named branch?
-
Casebash almost 14 years1. Article was updated: "As of Mercurial 1.6 bookmarks can be pushed and pulled between repositories." 2. This explains the differences, but not why you would want to use one over the other
-
Ry4an Brase almost 14 yearsThe differences should help you pick which model works best for you, and each has clear tradeoffs. Do you want your branch names to stay around forever? Use named branches. Etc.
-
Vadim Fint over 13 yearsthe mercurial wiki says that named branches is for "long living branches of development". So, I would create branch for new-major-release, but use bookmarks for fix-bug-XXX branch.
-
Dan Passaro about 9 years"only one head at a time can be pointed to by the same bookmark" AFAIK this is not true - you can have as many bookmarks as you like on any commit, head or not. However only one bookmark can be -active- at a time (i.e. committing will automatically advance that bookmark).
-
Kevin about 7 years@DanPassaro: I think you read that sentence the wrong way round. It's saying no single bookmark can point to more than one commit at once (which seems perfectly obvious to me but might not be obvious to someone with less Mercurial experience).
-
Dan Passaro about 7 years@Kevin Yes, you are correct. I can't remember what idea I had in my head when I made that comment. The reference to active bookmarks also seems to be totally irrelevant and makes little sense to me. Hopefully I was drunk at the time.