I'm not sure why this is so hard to figure out or google, but I am trying to take changes I made to a private branch and push them to the default branch.
In other words:
- I pulled from the default branch a few weeks back and made major changes
- Since then, I have finished my work
- I then merged the code from the original default branch (just the code, the HG is still set to the "NewBranch"
- Now that the code works, I want to commit and push these changes back to the default branch and continue my development from there.
But I can't find any information on how to do that. If I switch branches, I lose all my changesets since I am still in the NewBranch. I can't figure out what rebase or transplant do and can't find guides that explain scenarios on what they could be used for... So hopefully someone here knows what to do!
I am specifically using Mercurial on Eclipse but I am fine doing this on command line if its easier.
merge
is the way to get changes from one branch into another. I know you mergeddefault
into feature, but now you go the other way. Here's an example where numbered changesets come from other people and lettered changesets comes from you:Before you do anything you clone and have this:
then you create your branch named 'feature' and do two commits on it, yielding:
then you
hg pull
to get changes to default since you diverged down in your local repository:now you want their changes (5 and 6) integrated into your branch so you do:
which yields:
If I'm understanding correctly, you've already done all that, so now you just need to bring your branch, including the new merge commit, C, into default, which again is done via a merge:
that yields:
That looks like a lot of work drawn out that way, but in practice it's usually just:
and if the
pull
didn't bring down any new work from other you can skip the merging of default into yours.That does create two new merge changesets. They're easily hidden on
hg log
if you find them unhelpful (some people love having a record of which direction each merge went), but if you want to avoid them entirely you can usebookmarks
(very similar to git branches) instead of "named branches" for your features -- then you'll avoid a merge changeset when coming back since it would be the spiritual equivalent of what git calls a "fast forward" merge.