[git] I can't delete a remote master branch on git

I need to delete a master branch, but it's proving to be hard. I just want to clean that branch out and start new. I am deleting from the dev branch. I want master on GitHub to be clean.

 # git push origin --delete master

> To https://github.com/mymasterb.git  ! [remote rejected] master
> (deletion of the current branch prohibited) error: failed to push some
> refs to 'https://github.com/mymaster.git'

How do I quite simply start my master with a fresh slate?

This question is related to git github

The answer is


To answer the question literally (since GitHub is not in the question title), also be aware of this post over on superuser. EDIT: Answer copied here in relevant part, slightly modified for clarity in square brackets:

You're getting rejected because you're trying to delete the branch that your origin has currently "checked out".

If you have direct access to the repo, you can just open up a shell [in the bare repo] directory and use good old git branch to see what branch origin is currently on. To change it to another branch, you have to use git symbolic-ref HEAD refs/heads/another-branch.


The quickest way is to switch default branch from master to another and you can remove master branch from the web interface.