rits
rits

Reputation: 1544

Change main branch in bitbucket?

I messed up and pushed a branch to bitbucket that wasn't meant to be main branch.

enter image description here

I can't make a new repository and I have limited access to this one. I tried renaming it. I ended up deleting .git folder, now I can't push to that branch or pull it. When I try to pull it says:

(files)...
Please move or remove them before you can merge.
Aborting

I want to have branch named main (as the main branch) and then cms-fe that branches out from it.

Can someone help me get out from this mess?

Upvotes: 3

Views: 2764

Answers (1)

CodeWizard
CodeWizard

Reputation: 142174

I want to have branch named main (as the main branch) and then cms-fe that branches out from it.

Since you dont have admin rights we will have to rename your branch and than push it with the new name:

# rename the local branch
git branch -m cms-fe main

Now that the branch has a new name we will push the new name to the remote

git push origin main

Now we will delete the old branch that you pushed with the old name

git push origin :cms-fe

Branch out from the main branch

git checkout main
git checkout -b cms-fe

# upload the branch to the remote server
git push origin cms-fe

Upvotes: 3

Related Questions