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

Prevent accidental deletion of a branch?

Petr Horcicka August 19, 2018

Hello,

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

2 votes
Answer accepted
Mohamed Adel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 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.

 

Thanks

Adel 

jredmond
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 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.

Petr Horcicka August 20, 2018

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!

Dave Hollingshead August 6, 2019

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

https://i.imgur.com/75VVQab.png

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.

Henrik Zagerholm September 11, 2019

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
0 votes
Pablo Leone August 26, 2020

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.

0 votes
Logan Schmidt September 9, 2019

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.

https://stackoverflow.com/a/6827045

jredmond
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 9, 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.

Logan Schmidt September 9, 2019

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events