Delete branches in Bitbucket

301,456

Solution 1

If the branches are only local, you can use -d if the branch has been merged, like

git branch -d branch-name

If the branch contains code you never plan on merging, use -D instead.

If the branch is in the upstream repo (on Bitbucket) you can remove the remote reference by

git push origin :branch-name

Also, if you're on the Bitbucket website, you can remove branches you've pushed by going to the Feature branches tab under Commits on the site. There you'll find an ellipsis icon. Click that, then choose Delete branch. Just be sure you want to drop all the changes there!

enter image description here

Solution 2

For deleting branch from Bitbucket,

  1. Go to Overview (Your repository > branches in the left sidebar)
  2. Click the number of branches (that should show you the list of branches)
  3. Click on the branch that you want to delete
  4. On top right corner, click the 3 dots (besides Merge button).
  5. There is the option of "Delete Branch" if you have rights.

Solution 3

In addition to the answer given by @Marcus you can now also delete a remote branch via:

git push [remote-name] --delete [branch-name] 

Solution 4

I could delete most of my branches but one looked like this and I could not delete it:

enter image description here

Turned out someone had set Branch permissions under Settings and from there unchecked Allow deleting this branch. Hope this can help someone.

enter image description here

Update: Where settings are located from question in comment. Enter the repository that you wan't to edit to get the menu. You might need admin privileges to change this.

enter image description here

Solution 5

in Bitbucket go to branches in left hand side menu.

  1. Select your branch you want to delete.
  2. Go to action column, click on three dots (...) and select delete.
Share:
301,456

Related videos on Youtube

catherine
Author by

catherine

Updated on March 04, 2022

Comments

  • catherine
    catherine about 2 years

    I've created lots of branches in one of our repositories. Those branches are for testing before it will be pulled to the master. Now I see lots of them on the list and they we will never use it again. How to delete those branches directly to Bitbucket?

  • Admin
    Admin over 6 years
    Where can one find the "Settings"? I have to delete the main branch or all the files in it. How do I do it?
  • niico
    niico over 5 years
    Where is 'overview'? If you mean Source, I see no 'Delete Branch' option under the ...
  • Noumenon
    Noumenon over 5 years
    Step 1 should be "go to your repo and click 'branches' in the left sidebar."
  • jersey bean
    jersey bean almost 5 years
    If I run 'git branch -r', I notice that BB isn't deleting the branch from the server. It no longer shows up in the GUI, but its shows on the git server.
  • Suncat2000
    Suncat2000 almost 3 years
    There are some branches that BitBucket simply will not allow deleting.
  • DonBaka
    DonBaka over 2 years
    Looks like not allowing for me: remote: external-pre-receive-hook declined remote: fatal: not a tree object remote: tar: This does not look like a tar archive remote: tar: Exiting with failure status due to previous errors
  • Styszma
    Styszma over 2 years
    @jerseybean - git remote prune origin should help you out. I'm 2 years later but hopefully it will help someone.
  • user1315621
    user1315621 about 2 years
    That's on Bitbucket website