Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

rpinson@rpinson:~/dev/charismanie$ git remote show origin 
* remote origin
  Fetch URL: git@github.com:raphink/Charismanie.git
  Push  URL: git@github.com:raphink/Charismanie.git
  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
To git@github.com:raphink/Charismanie.git
 ! [remote rejected] xetex (deletion of the current branch prohibited)
error: failed to push some refs to 'git@github.com:raphink/Charismanie.git'

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

share|improve this question
    
support.github.com/discussions/repos/… 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: stackoverflow.com/questions/3301956/… –  Ciro Santilli Feb 2 at 21:00

2 Answers 2

up vote 41 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
1  
Awesome! was looking how to do that on GitHub for 20 minutes before I searched here. –  rlemon Jan 20 '12 at 20:55
1  
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 at 21:19
    
github default branch is not a git feature, so no. –  ℝaphink Feb 2 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.