How do I delete origin/master in Git
Emily Wong
I cannot remove origin/master from my server. No idea why.
The error message is the following
remote: error: By default, deleting the current branch is denied, because the next
remote: error: 'git clone' won't result in any file checked out, causing confusion.
remote: error:
remote: error: You can set 'receive.denyDeleteCurrent' configuration variable to
remote: error: 'warn' or 'ignore' in the remote repository to allow deleting the
remote: error: current branch, with or without a warning message.
remote: error:
remote: error: To squelch this message, you can set it to 'refuse'.
remote: error: refusing to delete the current branch: refs/heads/master
To :/export/home/a/elabshare/git/ID-check.git ! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to ':/export/home/a/elabshare/git/ID-check.git'No, I am not using Github.
92 Answers
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).
1In lieu of actually removing master from the server, you can replace it like this:
git push origin otherbranch:master -fThat 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.
2