开发者

Mercurial merge / remove a feature branch

开发者 https://www.devze.com 2023-03-12 22:49 出处:网络
I am trying to work out how to use the Branch-per-feature approach in mercurial but having created a branch to work in, and merged it back to default, am unable to push my changes back up to my master

I am trying to work out how to use the Branch-per-feature approach in mercurial but having created a branch to work in, and merged it back to default, am unable to push my changes back up to my master repository. What is best to do?

Mercurial merge / remove a feature branch

I created a branch "Gauge customisation", did some work in that branch and then merged it back into the default. Carried on with a few more changes in default and now I want to commit 开发者_运维技巧this back to my master repository. But when I try I get:

abort: push creates new remote branches: Gauge customisation!

hint: use 'hg push --new-branch' to create new remote branches

I didn't think the branching would show up in the master repo and that by merging it locally I could somehow work in the branch (or potentially branches) and then when I've tested everything, push it up to the master repo.

Should the Gauge customisation branch still show up? Really I thought I'd only see default at this stage? But is that me not understanding the tools properly? Should I be creating the remote branch? Ideally I'd like to be able to open a branch per feature and have 3 or 4 such branches running at any one time (it's the way my company works) so I'd like to get a solid grasp of things now.


Technically you could just commit the new branch to the master repo using --new-branch. As displayed in your screenshot, there is not really a new branch with a head from a topological view, but from a namespace view, i.e. when hg aborts your push, it just wants your explicit acknowledgement to add a new branch (name) to the remote repo.

However, for tasks like your's -- temporary feature branches -- a more common workflow is to not use named branches but anonymous/bookmarked branches or separate clones. Named branches usually are used for long-living branches like stable, legacy, and so on. If you create an anonymous/bookmarked branch and merge it back when its feature is finished, hg won't complain when pushing.

An often recommended reading in that context is A Guide to Branching in Mercurial.


Merging two branches does not get rid of either of them. You will need to close your feature branch manually by switching to it and doing:

hg commit --close-branch -m 'Closing branch'
0

精彩评论

暂无评论...
验证码 换一张
取 消