Cannot delete remote branch; "remote: permission denied to delete branch (name)"

Issue #9097 resolved
Kris Randall created an issue

I have deleted a branch locally using :

git branch -d (branch_name)

I then attempted to delete the remote branch using :

git push origin :(branch_name)

however that command gives me the following error :

remote: permission denied to delete branch (branch_name)
To https://(my_account)
! [remote rejected] (branch_name) (pre-receive hook declined)
error: failed to push some refs to 'https://(my_account)'

Why am I unable to delete the branch at origin?
Am I doing something wrong?

Comments (10)

  1. Daniel Bennett staff

    No, the branch cannot be deleted not because you are doing something wrong, but because the repository administrator has set branch-level restrictions on the repo. Can you check to make sure the branch isn't restricted by an admin?

  2. Amit Andharia

    any updates on this? I'm also getting the same error.... I'm the admin, i've just one branch master, i want to delete it. no branch level restriction applied in settings > branches.

  3. Rajib Paudyal

    Unfortunately once the issue is marked SOLVED, no one dares to turn back to it, its just a normal development process where you have to close the tickets instead of open the dead grave. So, you might try to open the new issue above, if you still have problem.

    For me, In Settings->Branch Management I had prevent deletion of these branch to * (that means all). So, I had to remove that one from there, delete the branch and put that * back again.

    I wish if Bitbucket devs could have taken more time to explain more precisely why they have closed the issue without proper explanation. Instead of just closing the issue due to inactivity without even responding to ask more info from the OP.

    I agree first comment is Spot-On and gives you clear hint where the problem is, BUT BUT BUT everyone is not that smart enough to understand likewise looking for clear simple instructions.

    Anyways, I got my issue solved, cheers :-)

  4. Kris Randall reporter

    As the OP, I write to confirm that the original response from Dan was essentially correct for my issue - the admin of the repo told me that he had set the repo so that deletes were not allowed, and that has since been changed.
    Thanks for the response, and for your further comments Rajib.

    Amit -
    If you are trying to delete the "master" branch, I am guessing that is not allowed, there is not really any repo without a master branch as far as I understand - you probably want to do an action which deletes the repo instead.
    I don't know if that helps - I hope you get it sorted.

  5. Kris Randall reporter

    Hi Amit - I'm not all that familiar with bitbucket I'm afraid - except as a repo and a tool for looking at commits and such - I haven't actually used the issue tracker or wiki before.

    Maybe Dan or Brodie can help?

    Otherwise, I think this is a different issue and maybe deserves it's own post "How do I delete the repo but keep the issue tracker and wiki?"

  6. Log in to comment