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
I could delete most of my branches but one looked like this and I could not delete it:
Turned out someone had set Branch permissions
under Settings
and from there unchecked Allow deleting this branch
. Hope this can help someone.
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.
If you like fun, then you can just go to the listing page of you branches (for example merged) and just run in the javascript console:
document.querySelectorAll('tr td div a:first-child').forEach(function(item) { fetch('https://bitbucket.org/snippets/new?owner=<yourprofilenick>', {'credentials': 'same-origin'}).then((response) => {return response.text()}).then(function(string) { return /'csrfmiddlewaretoken' value='(.*)'/g.exec(string)[1] }).then(function(csrf) { if (!~item.innerText.indexOf('/')) return;
fetch(`https://bitbucket.org/!api/2.0/repositories/<your_organization_path>/refs/branches/${item.innerText}`, {headers: {"x-csrftoken": csrf}, credentials: "same-origin", method: 'DELETE'}).then(() => console.log(`${item.innerText} DELETED!`)) }) })
<yourprofilenick>
with your BitBucket nick<your_organization_path>
with your organization pathFirst we need a page with with a CSRF token in the page source, so I choose:
https://bitbucket.org/snippets/new?owner=<yourprofilenick>
Then for each branch (in a branch listing) it gets CSRF token and deletes that branch.
Remeber to prevent sensitive branches before deleting in repo settings.
It WON'T delete the main branch.
You have to be logged in.
It deletes only branches visible on that page (so to delete the rest of branches you have to go to the next page).
git push <repository> -d <branch>
to get the repository
, type git remote -v
in command line
Step 1 : Login in Bitbucket
Step 2 : Select Your Repository in Repositories list.
Step 3 : Select branches in left hand side menu.
Step4 : Cursor point on branch click on three dots (...) Select Delete (See in Bellow Image)
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!
in Bitbucket go to branches in left hand side menu.