Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Prevent accidental deletion of a branch?


is there a way to prevent an accidental deletion of a branch, e.g. when merging a Pull Request and someone clicks on "Delete source branch on merge"?

It is about Bitbucket Cloud.

Thank you

3 answers

1 accepted

1 vote
Answer accepted
Mohamed Adel Community Leader Aug 19, 2018

Hi Jaroslav, 

Can you check  Tim's solution ,it will do the following :

  1. Deny deletion of branches.
  2. Deny force pushes to branches.
  3. Deny deletion of tags.
  4. Deny modification of tags.




jredmond Atlassian Team Aug 20, 2018

Unfortunately, Tim's solution is for Bitbucket Server.

For Bitbucket Cloud, however, you can use branch permissions to prevent users from deleting the branch in question.

Hello Tom,

there is a new option under custom settings: "Deleting this branch is not allowed"

I swear two days ago it wasn't there :-)

Thanks a lot!

I'm not seeing an option to prevent deletion of master or a branch "type" (like Development)...

It's very easy in a git GUI or CLI to accidentally select to delete the remote branch or mistype an option.

I'm not sure a plugin is feasible without knowing exactly what it's seeing or doing in its code execution (privacy & security issue), and also an incompatibility or update can cause disruption if we're relying on it.

Hey, just add a user to write permissions and then you will get checkboxes for controlling deletion and rewriting history.

Like guy.carpenter likes this

There's a bug in Jira! If no user is on the write access field you won't see the options to prevent the branch to be deleted. Add a user, check/uncheck the option, remove the user and save.

Just a thought/idea, you may want to solve this problem at a lower layer, in `git` you can use an update-hook and simply prevent the deletion. This should live with the repo and protect it where it sits Bitbucket cloud or server.

jredmond Atlassian Team Sep 09, 2019

Hooks are not included in pushes or pulls, though, and users do not have direct filesystem access to the .git directory in a repo on Bitbucket Cloud.

@jredmondfair enough. I also assumed users could edit repos in Bitbucket Cloud.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,827 views 10 16
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you