Make another branch default?

I have a Mercurial repo at Bitbucket and on my local machine, both are mirrors, up to date. I created a feature branch, reflected in both repos. I did all my work in the feature branch.

The feature branch is now complete and I want to now make it the default for the main repo and my local copy. I don’t really care about the default branch, enough work has gone into the feature branch that all I want to do is designate it as the new default.

  • Why only push to a branch?
  • Organizing git branches
  • Merge branch that was created with the same name as deleted one
  • Github remote Branch and Local Git Repo
  • How to move git branch up tree (reverse rebase)
  • How to get git parent branch name of current branch?
  • I don’t think I want to merge nor should I? How can I do this so both local and remote don’t get confused?

  • How to git clone an SVN repository where all branches are located in root?
  • Git: should I delete a (unmerged) branch when it is no longer active?
  • Change Git Parent Branch
  • What's your ideal branch architecture within git for web applications?
  • Separate git branch into multiple branches to merge to master
  • Migrating an SVN repository to some distributed VCS (Git or Mercurial)
  • 4 Solutions collect form web for “Make another branch default?”

    Just merge feature-branch into default then close feature-branch:

    $ hg checkout default
    $ hg merge feature-branch
    $ hg commit
    $ hg checkout feature-branch
    $ hg commit --close-branch

    There is no more clean and sensible way (that I’m aware of) to “make feature-branch the default”.

    One thing that wouldn’t be as nice, but you could do, is to make a commit to default on top of feature-branch:

    $ hg checkout feature-branch
    $ hg branch default
    $ hg commit

    But this would leave two heads in the default branch, which is suboptimal.

    Since Mercurial 2.4, you can create an bookmark called @ and Mercurial will checkout that revision new clones.

    However, I would still try to stick with using default as the branch where the main development takes place. Doing so will cause the least amount of surprise for developers already used to Mercurial — the wiki describes the standard way to use branches in Mercurial.

    If you follow the conventional advice of using default as the main branch for development, then you should close your feature branch before you merge it back:

    $ hg update feature-branch
    $ hg commit --close-branch -m "Feature done, merging into default branch"
    $ hg update default
    $ hg merge feature-branch
    $ hg commit

    If you haven’t done any work at all on the default branch since your started the feature branch, then this merge will be trivial and have no conflicts. Otherwise you’ll have to resolve conflicts. If you’re sure you want to keep everything from the feature branch, then you can do

    $ hg merge --noninteractive --tool internal:local feature-branch
    $ hg revert --all --rev feature-branch

    instead of just hg merge above. That will make sure that the new commit on default look exactly like the last commit on feature-branch.

    I succeded without merging by closing the default branch.

    in my development repository working directory:

    $ hg update default

    $ hg commit --close

    then my development branch became the new default branch.
    But i do not know the rules for why my development branch was choosen
    as the new default.
    i think it is because it was my tip ?
    (or maybe last changed branch? (tip?))

    I also think that you have to repeat that next time.
    Because i think my chosen branch name was “overwritten” by the ‘default’ name.

    It would be nice to have branch name.



    I wanted to do just what you described and hunted around until I found an answer which uses the revert command to do just what you describe. Here is the code I used:

    hg revert –all –rev ${1}

    hg commit -m “Restoring branch ${1} as default”

    where ${1} is the number of the revision or the name of the branch. These two lines are actually part of a bash script, but they work fine on their own if you want to do it manually.

    This is useful if you need to add a hot fix to a release branch, but need to build from default (until we get our CI tools right and able to build from branches and later do away with release branches as well).

    Git Baby is a git and github fan, let's start git clone.