23

I try to remove the git remote branch on the bitbucket by git push command:

qty:workspace qrtt1$ git push origin :my_branch
remote: fatal: bad object 0000000000000000000000000000000000000000
remote: bb/acl: qrtt1 is allowed. accepted payload.
remote: fatal: bad object 0000000000000000000000000000000000000000
To git@bitbucket.org:qrtt1/workspace.git
 - [deleted]         my_branch

However, only the branch in my local stroage removed. How do I remove it ?

PS. I can remove the remote branch in the same way from github.

qrtt1
  • 7,746
  • 8
  • 42
  • 62

3 Answers3

29

You can't delete a branch from Bitbucket if that branch is set as the Main Branch. You need to go into the Admin section of your Bitbucket repository and select a different branch for the Main Branch. You should then be able to remote the branch using

git push <repository> :<branch>
smbruce
  • 391
  • 3
  • 3
  • In the current version of BitBucket there's no Admin section! It's also not possible to set other branch as Main Branch! The workaround is to save the repo to local pc, then remove the repo, then create new repo with needed Main Branch. – Tim Long Nov 09 '15 at 23:13
10

Eventhough, it says those errors / warnings (probably some post hook that BitBucket has that is not proper?), it has gone ahead and deleted the my_branch branch, as indicated by the last line. Go to the web UI and confirm that the branch is indeed gone.

manojlds
  • 290,304
  • 63
  • 469
  • 417
  • I try to find where to delete the remote branch from web-ui, but in the admin tab only delete repo. Could you give me some hints ? – qrtt1 Nov 08 '11 at 05:10
  • @qrtt1 - IS the branch still there in the UI? I replicated what you were trying and the branch was gone, despite the above messages – manojlds Nov 08 '11 at 05:20
  • Yes, after removing, my branch list still contains my_branch. I consider it's a bug, but I cannot reproduce it now. I will close this discuss. – qrtt1 Nov 08 '11 at 05:47
5

I found the same problem, only the local is removed but not remote. Finally I found the solution from http://groups.google.com/group/gitorious/browse_thread/thread/5afe8581cdd96d2b, just use

git push <repository> :<branch>

After that checked on bitbucket website, it should be gone.

haxpor
  • 2,431
  • 3
  • 27
  • 46