In a git project I did some refactoring in a branch and now this branch should be a new project. I moved this project from github to bitbucket. Now I want to delete the old master and make the refactoring branch the new master.
I tried to delete the master:
$ git branch -D master
Deleted branch master (was a947288).
$ git push origin :master
remote: error: refusing to delete the current branch: refs/heads/master
! [remote rejected] master (deletion of the current branch prohibited)
In the bitbucket frontend I couldn't delete the master neither. So how could I achive that? Or do I have to create a new project and push the refactoring branch into its master?
To completely remove a remote branch, you need to use the git push origin command with a -d flag, then specify the name of the remote branch. So the syntax representing the command for removing a remote branch looks like this: git push origin -d branch-name .
In Bitbucket go to branches on the left hand side menu. Select your branch you want to delete. Go to action column, click on three dots (...) and select "delete branch".
Can the master branch be deleted? The master branch is just a type of branch in the repository, which is also the default branch by default. But, as a rule in Git, default branches cannot be deleted. So, to delete the master branch first, the user has to change the default branch.
You have to change the main branch of bibucket before being able to delete it.
As long as master
is the main branch, bitbucket will prevent you to do so (which make sense).
In Bitbucket UI:
Duplicates :
When you are pushing a deletion, you must first change the default branch (on GitHub) to your new branch.
That means you must have first push your new branch on GitHub in order to select it as default branch.
Then you can delete master on GitHub.
The same idea applies on BitBucket:
- Select the repository
- Select Administration
- In Repository Details, set Main branch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With