How to delete a branch on Bit Bucket that has been deleted locally?

This didn't help:

git push repository :branch

Any body know how?


3 answers

1 accepted

This widget could not be displayed.


This syntax is correct

git push repository :branch

In this case, repository is referring to the alias you configured when you setup your git remote initiall or recently. The default if you don't specify one is origin. In other words, your command should look like:

git push origin :{branch_name}

You can confirm what the alias is by looking at the contents of the file .git/config or by running the command

git remote -v

In that listing you'll see the alias and URL. That is the configuration of the URL alias to your remote. For more information about git remotes, see the official documentation.

If you still have more questions about the usage of git in general, please ask it here. We'd love to continue to share this information with the community!

Hi Marcus,

Sorry but that command gives the following error:

David-Chamberss-MacBook-Pro:ZS1 davidchambers$ git push origin :2013_Develop_ZS1_into_MIDI_Metrics_Tool_
error: unable to push to unqualified destination: 2013_Develop_ZS1_into_MIDI_Metrics_Tool_
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to ''


Any ideas?

Thanks for trying

This means that git doesn't know what branch you are referring to. I took a look at your repo, and it would appear that your branches full name includes (free) in it. You can check this by running

git branch -a

Maybe try copy/pasting the exact full name of the branch? When you are pushing up this change, keep in mind the ref is quite literally a file with a reference to a commit sitting on the remote server. You need to use the exact name when referring to it.

Note with the ( and ) you may need to use \( and \) as escape characters if you are using OSX or Unix like shells.

Yes, thanks very much Marcus, it's fixed now. My mistake.


This widget could not be displayed.

Is that your main branch? You can't delete the main branch, you need to choose a different branch as the main branch then you can use the command you mentioned.

All the best

If that's your Main branch you can't delete it. You'll need to go to the admin section of your BitBucket repository and select a different branch for the main branch.

Hi Razaq,

That could be the problem. How do I change the main branch on the server? Thanks

No, my main branch is Master.

I cd'ed to the local directory with my project and tried the follwoing and got these errors:

andrea-xps:ZS1 davidchambers$ git push ZS1 :2013_Develop_ZS1_into_MIDI_Metrics_Tool_
fatal: 'ZS1' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
andrea-xps:ZS1 davidchambers$ git push Zoabis/zs1 :2013_Develop_ZS1_into_MIDI_Metrics_Tool_
fatal: 'Zoabis/zs1' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
andrea-xps:ZS1 davidchambers$

I thought this was the URL of my repo:


Thanks for your help so far

This widget could not be displayed.

hmm..this is actually beyond my BitBucket experience :(. I suggest you consult our BitBucket support team at under the bitbucket project. Am sure you'll get the help you need.

Will do. Thanks for trying anyway!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Friday in Bitbucket

What is your #1 piece of advice to new users getting started using Bitbucket?

Hello Community! My name is Claire Maynard, and I’m a Product Marketing Manager on the Bitbucket team. I’m interested in hearing what advice or tips you have for new users getting started on ...

169 views 9 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you