Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the main branch in BitBucket?

Tags:

git

bitbucket

I have a repo on bitbucket with two branches. First branch is master with a fake content, then I have another one called trunk with the correct content.

I would like to change the main branch to trunk (actually is master). I found that in the repo adminsitration are on bitbucket web I could change this but I couldn't.

Finally I would like to understand if is possible to do this through terminal from my local repo.

Maybe an easy thing is to delete contents from master and merge trunk into master and the delete trunk but I neither know how to do this.

like image 934
mrc Avatar asked May 31 '16 15:05

mrc


People also ask

What is default branch in Bitbucket?

The default branch is master (you will be on this branch after a clone or when browsing a repository). In Bitbucket you can change the default branch in the Repository Settings screen.


3 Answers

  1. Repositories

enter image description here

  1. Select repository
  2. Settings

enter image description here

  1. Main branch: master

enter image description here

  1. Save repository details

enter image description here

like image 199
030 Avatar answered Oct 18 '22 23:10

030


With two branches named trunk and master, change master to the HEAD of the repository and delete trunk:

git symbolic-ref HEAD refs/heads/master
git branch -d trunk

From:

https://answers.atlassian.com/questions/280944/how-to-change-main-branch-in-bitbucket

like image 22
Destrif Avatar answered Oct 18 '22 23:10

Destrif


Relevant for folks who are looking at this question in 2022

The menu options have changed a bit. The following steps can help you achieve the same.

  1. Go to your repository.
  2. Click on repository settings on the left-hand side menu bar.
  3. Click on repository details ( if not already selected ).
  4. You should be able to see a dropdown with advanced written on it ( refer to image ).
  5. In that drop-down menu, you should be able to find the main branch settings.

I hope it helps :)

enter image description here

like image 4
AssaultKoder95 Avatar answered Oct 18 '22 23:10

AssaultKoder95