Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to only push to one branch in Hg?

I have a Hg repo with 3 branches in it, but two of them are inactive (since I have already merged them into my default branch). hg heads shows 3 heads, one for each branch, even though hg branches shows 2 of those branches as 'inactive'.

When I try to push my default branch (using hg push --branch default http://...) to another repo, the merge is aborted with the message "abort: push creates new remote branches: !"

From the Hg push man pages, "By default, push will not allow creation of new heads at the destination, since multiple heads would make it unclear which head to use. In this situation, it is recommended to pull and merge before pushing."

I've already done that, but I still cant push --branch default without it getting aborted.

Any help is appreciated. Thanks!

like image 502
simon Avatar asked Feb 02 '11 21:02

simon


People also ask

What is mercurial branch?

Mercurial branch name is an attribute associated with a changeset. A new branch name can be started in the middle of a development line, not necessarily at a diverging point.


2 Answers

If changesets on default have ancestor changesets on other branchs you have to push those changesets too. It's not possible for a changeset to exist in a repo without all of its changesets also existing.

So try:

hg push --branch default --new-branch

which says "yeah, I know this push sends across a branch name that the remote repo hasn't previously seen before" (it also requires Mercurial 1.6 or later IIRC)>

Also, you can take those inactive heads and make them closed heads with:

hg update thebranch
hg commit --close-branch -m 'closing'

Because "named branches are forever" many folks choose to reserve them for long lived concepts like "stable" and "experimental" and use bookmarks, anonymous branches, or clones for features, releases, and other transitory things. See this for a guide on those other options.

like image 176
Ry4an Brase Avatar answered Sep 25 '22 11:09

Ry4an Brase


To push a single branch you just use -b

hg push -b myBranch

as for the specific issue, you may want to look into closing branches. I know SourceTree offers it, but I'm not sure on the specifics

like image 20
Rembrandt Q. Einstein Avatar answered Sep 28 '22 11:09

Rembrandt Q. Einstein