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?

Thanks

3 answers

1 accepted

Hello,

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_
Password:
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 'https://Zoabis@bitbucket.org/Zoabis/zs1.git'

:-(

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.

Cheers

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:

https://bitbucket.org/Zoabis/zs1

??

Thanks for your help so far

hmm..this is actually beyond my BitBucket experience :(. I suggest you consult our BitBucket support team at support.atlassian.com 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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Asked 4 hours ago in Confluence

What are the resources that you use to learn more about Atlassian Products?

I am gathering information about resources available for Atlassian product knowledge transferring for a presentation in our local Atlassian User Group. I want to group them in four categories From ...

35 views 3 3
View question

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