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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Deleting the source branch when merging a pull request

Hi,

 

Stash has the option to delete the source branch when merging a pull request.

 Is there a way to limit this? I would expect that this is configurable so that this check box will be disabled for certain branches, or that branch permissions will include 'delete' in addition to 'read' and 'write'.

We experienced a human error of accidentally deleting a branch (not feature) in this way, and we want to prevent this somehow.

 

Thanks,

Moti.

6 answers

1 vote
ThiagoBomfim Atlassian Team Sep 16, 2014

Hi Moti,

What you are asking is already implemented. From the Merging a Pull Request document:

In the 'Merge Pull Request' dialog, you can check Delete branch if you no longer need that branch in the repository. Stash checks on a few things before allowing the deletion – the branch being merged will not be deleted if:

  • The branch is the default repository branch.
  • The user does not have permission to delete the branch.
  • The branch is subject to an open pull request.

In regards to the point "The user does not have permission to delete the branch.", user in this context means the "user merging the Pull Request". Make sure you go through the Using branch permissions document. Once you set this up, you will be able to prevent unauthorised users merging the pull request from deleting the branch.

Another important point to observe here: if you are not sure that this branch should be at all deleted, why check the box during the PR creation in the first place? Stash offers ways of stopping the Pull Request from being accidentally merged. Stash implements Checks for merging for Pull Requests. Or you can write your own plugin and/or download a plugin like the Stash auto unapprove plugin.

Let me know if this was helpful.

Best regards,
Thiago Bomfim
Atlassian Support - DevTools

Hi Thiago,

 

we have similar issue , I want to understand if the Master got deleted during the merge

then what would be the reason ? How can we work RCA to investigate the issue ?

Any suggestion ?

 

Thanks,

Vijay

MOti?

I would expect that if somebody has no write access to a branch, they also cannot delete the branch.

If they are the ones doing the merge, they must have write access. I'm trying to prevent accidental deletion of source branches by the merger

My point is if somebody has no write access to a branch (the source branch here), then they should not be able to delete that branch via any interface. If this is not so, report it as a bug here.

But this is not my case. I want to restrict deletion of certain branches (at least from the merge pull request dialog), even if the user has write permissions to the branch.

That sounds like a feature request, you can also make it in the same place.

We have the same problem. We'd like protect branch (release-*, feature-*) from deletion after merge it into master

Hi Thiago,

Thanks for your answer.

Unfortunately, this does not solve my use case.
Let's say we are following the gitflow branching model.

  • The release manager can merge changes from feature branches into master (and deleting the feature branches in the process).
  • Then, the release manager can merge master into a release branch - he must have write access to the release branch in order to perform the merge, but he can't accidentally delete master (the source) since it is the default branch

  • Now, the release manager want to merge the release branch into production. He has write access to both branches, and he accidentally checks the 'delete source branch' since he is used to do this with feature branches. In this case the release branch (source) will be accidentally deleted, and this is what i want to prevent.

There is no 'delete' permission - only read or write. Also, there is no way to disable the check-box via configuration for certain branches. Accidental merging is not something i'm concerned about at the moment.

I was hoping maybe there is a way to prevent this, but it seems like there isn't.

 

Thanks,

Moti.

Hi Moti, I am facing the exact same issue. Did you get a resolution for the problem faced? If yes, can you share?

Under branch permission you can add Permissions for certain branches and there you probably have your branches which also have limited access rights. When you edit your branch permission  there is also the option to flag the branch with "Prevent branch deletion".

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Bitbucket

Contest: Share your custom Bitbucket Pipe and win

Announced in this blog, this holiday season we’re celebrating all things CI/CD and between now and the end of 2019 we’ll be showcasing content, use cases, feature announcements and more. One featur...

2,126 views 11 6
Join discussion

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