How do I delete origin/master in Git

Solution 1:

Fun fact: even remote repositories are on a branch. 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 bare repor 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.

If you are using a service like Github or Gitorious, you're going to have to use the UI the tool provides you to make the change (see this answer for how to do that in common tools).

Solution 2:

In lieu of actually removing master from the server, you can replace it like this:

git push origin otherbranch:master -f

That will replace master with the contents of otherbranch, but it'll still be called master on the remote. And then you can check out master as master in your local.