A Guide to Branching in Mercurial

本文介绍了Mercurial中使用命名分支进行版本控制的方法,包括创建、使用和更新分支的操作,以及如何通过指定修订版本来简化操作流程。此外,文章还提到了Mercurial与Git在分支处理上的不同之处,并提供了在不同场景下使用Mercurial进行分支管理的实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文地址:http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/

 

Branching with Named Branches

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:

  • Running hg update default would update to changeset 3, which is the tip of  the default branch.
  • Running 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.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值