David
David

Reputation: 12886

Push mercurial merged branch without history

Given that I have created a branch in Mercurial how can I push the resulting merge of that branch to a remote repository without the history of how I got to that merged branch result. For example.

[a] - [b] -----------------[k]
     \                     /
      [g] - [h] - [i] - [j]

[a], [b] and [k] being the 'default' branch, [g] through [j] being the feature branch. Once I merge the feature branch into the default branch how can I have just [a] - [b] - [k] change sets in the remote repository when I push? I don't want to simply not see the branch, I do not want those change sets pushed to the remote repository at all. I don't care how I got to [k], I do care what the [k] end result is though.

I am currently leaning toward the branch by cloning method but how can I accomplish this with cloning? Would there also be a way to make this work with named branches?

I have been looking for an answer to this but there is so much documentation out there it's difficult to find this needle in a haystack.

Upvotes: 8

Views: 654

Answers (2)

Laurens Holst
Laurens Holst

Reputation: 21026

Instead of merging, you want to use hg rebase with the --collapse option.

hg rebase --collapse --source [g] --dest [b]

The rebase extension is shipped with Mercurial, you just need to enable it in your settings file.

p.s. If you have already committed the merge [k], you should rollback (or strip) it first before rebasing.

Upvotes: 7

Lazy Badger
Lazy Badger

Reputation: 97270

how can I push the resulting merge of that branch to a remote repository without the history of how I got to that merged branch result

No ways to get stripped history for merged branches

Upvotes: 0

Related Questions