Uploaded image for project: 'Bitbucket Server'
  1. Bitbucket Server
  2. BSERV-4142

Ability to filter and bulk delete merged or stale branches

    XMLWordPrintable

Details

    • 337
    • We collect Bitbucket feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

    Description

      Atlassian status as of Jan 2022

      Hi everyone,

      Thanks to everyone for voting and commenting on this suggestion. Your input in the comments helps us understand how this affects you and what you're hoping to accomplish with Bitbucket Data Center.

      We spend a significant amount of time determining our product investments in Bitbucket Data Center. Unfortunately, we are not planning to address this suggestion in the next 12 months. In the last year, we have resolved many of the highly voted suggestions like Reviewer groups, Pull request templates, capability to enable/disable source branch deletion on merging pull requests and our upcoming roadmap includes a number of other top voted suggestions, including repository archiving. Please check out our public roadmap for more details on the coming soon and future items.

      Meantime, for bulk deletion of merged branches you can periodically execute the following bash script. It deletes all remote branches that have been fully merged into the "current" checked-out branch (in our case this is "develop"): 

      #!/bin/bash
      
      # list merged branches
      BRANCHES=`git branch -r --merged | grep -v "*" | grep -v master | grep -v develop | grep -v release/ | grep -v hotfix/ | sed 's/origin\///'`
      printf "Removing branches: \n$BRANCHES"
      
      # delete all remote branches merged into the current branch (i.e. develop), excluding release/master/develop branches
      git branch -r --merged | grep -v "*" | grep -v master | grep -v develop | grep -v release/ | grep -v hotfix/ | sed 's/origin\///' | xargs -n 1 git push --delete origin

      It's also worth mentioning that since Bitbucket 7.15 admins can choose if delete source branch should be the default option on pull request merge. We believe defaulting deletion of source branches should help to prevent growth of merged and stale branches.

      I understand that this may be disappointing, but it’s important for us to be open, honest, and transparent with our customers. Product feedback is collected from many different sources and is evaluated when planning the product roadmap. You can learn more about our process here.

      Cheers,

      Anton Genkin
      Product Manager - Bitbucket Data Center & Server

      Original suggestion:

      Scenario: We have a ton of feature branches left over from past projects, also from using source tree gitflow, only the local branch is deleted.
      I want to be able to see which of these have been merged into a specified branch (i.e. master), so I can cull the old branches.

      This is no benefit to stash from a technical viewpoint, but it improves the usability by reducing the number of branches a developer has to walk through.

      We are only just starting to use 'pull requests' to do merges. So the existing functionality to 'delete' on merge does not apply.

      Prior to stash, I would simply map a network drive to the remote repo, and use the command line to locate and prune all merged branches.
      With stash, I am having to do this one at a time, via SourceTree's User Interface.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              2b327561e96c James Rickards
              Votes:
              187 Vote for this issue
              Watchers:
              105 Start watching this issue

              Dates

                Created:
                Updated: