11

By default a branch will remain in Bitbucket when a Pull Request (PR) has been merged. How to ensure that a branch will be removed after a PR has been removed?

enter image description here

When the option is enabled then the branch will be removed after the merge of a PR, but how to ensure that it is clicked by default to prevent that creators of the PR forget to click it and the branch remains in bitbucket?

030
  • 13,383
  • 17
  • 76
  • 178

3 Answers3

6

What I really want is to add a comment to the accepted answer, but I don't have enough reputation to do so. So I'll note it here. I've closed BSERV-10344 because it's in the wrong tracker. This question is about Bitbucket Cloud (bitbucket.org), not Bitbucket Server (the behind-the-firewall version). The correct issue tracker for the feature request is at https://bitbucket.org/site/master/issues.

Also, re: "I'm not sure why they use different language for that", it's because Bitbucket Cloud supports Mercurial as well as Git. In Mercurial it's not possible to delete a named branch; they can only be closed. Since its support for Mercurial predates its support for Git, the terminology used is to "close" the branch.

4

For Bitbucket Server you can set this up on a project or repo-level under Settings > Branches (under the Workflow section), scroll to the bottom and tick this setting on and press save:

branch-deletion-on-merge-setting

So all in all you have two options:

  1. Change this setting on a project-level and have all repos under it inherit the project's settings by default
  2. Change this setting on a repo-level (if you want only some of your repos to adhere to this)
jlo
  • 141
  • 2
4

Apparently selecting the Close branch option in the very dialogue illustrated in your question will actually delete the branch as well. From Why only "Close" a branch instead of "Delete" it?:

Ben Tatham Jun 15, 2014

It seems that I was mistaken. Marking a pull request to Close branch when merged, does indeed Delete it. I'm not sure why they use different language for that though.

Dan Cornilescu
  • 6,780
  • 2
  • 21
  • 45