Search code examples
gitgithubbranchbitbucketgit-remote

Changing the 'Main Branch' in remote Git repository


We are using two remote repositories on Bitbucket for the same project- where one is the one with most developments taking place at this moment and more people having access to it. The other is just for our team and only the team members have access to it. Right now we are pulling only from the first repository and pushing to both of them.

Our issue with the second repository (push only) is: the MAIN BRANCH there (which I assume to be the active HEAD) currently set to some branch 'branch-x' which is not the master branch. However, this branch was recently merged to the master and then removed from the other remote repo. But attempts to push this change to the second remote is failing with this message: [remote rejected] branch-x (deletion of the current branch prohibited). The git command I used for this is: git push origin --delete branch-x

Is there any way I can move the remote "main branch" from branch-x to master and then delete the branch-x?

I also have a tag question: how can I change the name of a remote repo, such as change the name of the second repo from origin to origin-2?


Solution

  • See this link for deleting master on github, I would guess the process is similar for bitbucket.

    To rename a remote use git remote rename OLD NEW