Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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?

like image 290
dartdog Avatar asked Mar 24 '11 19:03

dartdog


People also ask

What is default branch in git?

The default branch name in Git is master . As you start making commits, you're given a master branch that points to the last commit you made.


2 Answers

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.

like image 95
David Wolever Avatar answered Oct 06 '22 15:10

David Wolever


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.

like image 22
Martin Geisler Avatar answered Oct 06 '22 15:10

Martin Geisler