本文共 1460 字,大约阅读时间需要 4 分钟。
原文地址:
The third way of branching is to use Mercurial’s named branches. Some people prefer this method (myself included) and many others don’t.
To create a new named branch:
$ cd ~/src/test-project$ hg branch feature
When you commit the newly created changeset will be on the same branch as its parent, unless you’ve used hg branch
to mark it as being on a different one.
Using a branch name to specify a revision is shorthand for “the tip changeset of this named branch”. In this example repository:
hg update default
would update to changeset 3, which is the tip of the default
branch.hg update feature
would update to changeset 4, which is the tip of the feature
branch.In the past there was also the problem of not having a way to “close” a branch, which means that over time the list of branches could get huge. This was fixed in Mercurial 1.2 which introduced the --close-branch
option forhg commit
.
Mercurial will push/pull all branches by default, while git will push/pull only the current branch.
This is important if you’re a git user working with Mercurial. If you want to push/pull only a single branch with Mercurial you can use the --rev
option (-r
for short) and specify the tip revision of the branch:
$ hg push --rev branchname$ hg push --rev bookmarkname$ hg push --rev 4
If you specify a revision, Mercurial will push that changeset and any ancestors of it that the target doesn’t already have.
转载地址:http://xxhai.baihongyu.com/