Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to remove a remote branch with git:

rpinson@rpinson:~/dev/charismanie$ git remote show origin 
* remote origin
  Fetch URL:
  Push  URL:
  HEAD branch: xetex
  Remote branches:
    master tracked
    xetex  tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
rpinson@rpinson:~/dev/charismanie$ git push origin :xetex
remote: error: refusing to delete the current branch: refs/heads/xetex
 ! [remote rejected] xetex (deletion of the current branch prohibited)
error: failed to push some refs to ''

Is there a way I can remove this branch from the list of "Remote branches" so I can remove it?

share|improve this question… could help, perhaps? – VonC Jun 8 '11 at 8:44
I've tried that, it doesn't help. – ℝaphink Jun 8 '11 at 8:58
Possible cross site duplicate of:… – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Feb 2 '14 at 21:00
up vote 44 down vote accepted

The branch was set as default on github, preventing it from being deleted.

On github, I went to "Administration" in the project, reset the default branch to "master" and I was able to remove the xetex branch.

share|improve this answer
Awesome! was looking how to do that on GitHub for 20 minutes before I searched here. – rlemon Jan 20 '12 at 20:55
This also happens with BitBucket, and is fixed in a similar fashion. – John Bubriski Mar 8 '13 at 14:35
Is there no pure git way of doing it? – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Feb 1 '14 at 21:19
github default branch is not a git feature, so no. – ℝaphink Feb 2 '14 at 20:55

For what it's worth in BitBucket:

  • click on Settings in the left menu
  • under 'Repository Details' find 'Main Branch' drop down menu
  • select a different branch from the one you want to delete

There's also an option to prevent branch deletion under the 'Branch management' section, but you have to actively set that yourself first.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .