# Ensure branches are deleted after pull request merge

- Source: https://support.icompaas.com/support/solutions/articles/a_1789072807197968-ensure-branches-are-deleted-after-pull-request-merge
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [Version Control System (VCS)](https://support.icompaas.com/support/solutions/c_1781179095087930) › [Bitbucket](https://support.icompaas.com/support/solutions/folders/f_1781179159125832)
- Last updated: 2026-10-26
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

Description

This check verifies that Bitbucket repositories are configured to automatically delete source branches after a pull request is successfully merged. Enabling automatic branch deletion helps maintain repository cleanliness by removing temporary feature or development branches that are no longer required after changes are integrated into the target branch.

Note: Only repository-level branch restrictions are detected. Restrictions set only at the project level are not returned by Bitbucket’s API and will result in a FAIL. Configure the restriction at the repository level for accurate results.

Rationale

Merged branches that remain in a repository can accumulate over time, creating unnecessary clutter and making branch management more difficult. Automatically deleting branches after pull request completion reduces repository maintenance overhead, improves visibility of active development branches, and helps enforce a consistent branch lifecycle management process.

Impact

-   Remove merged feature branches automatically after successful pull request completion.
    
-   Reduce unnecessary branch accumulation within the repository.
    
-   Improve repository organization and branch visibility.
    
-   Reduce manual cleanup activities for repository maintainers.
    
-   Help enforce standardized branch management practices.
    

Default Value

Depends on repository configuration. Bitbucket repositories do not always have automatic branch deletion enabled by default. Repository administrators must configure the branching model settings to automatically delete branches after pull requests are merged.

Pre-Requisites

-   Repository administrator access
    
-   An existing Bitbucket repository
    

Test Plan

1.  Sign in to Bitbucket at [https://bitbucket.org](https://bitbucket.org/).
    
2.  Navigate to the target repository.
    
3.  Select Repository settings.
    
4.  Navigate to Branching model settings.
    
5.  Review the pull request merge configuration.
    
6.  Verify that the option to automatically delete branches after pull request merge is enabled.
    
7.  If automatic branch deletion is disabled, follow the implementation steps.
    

Implementation Steps

1.  Sign in to Bitbucket at [https://bitbucket.org](https://bitbucket.org/).
    
2.  Navigate to the target repository.
    
3.  Select Repository settings.
    
4.  Navigate to Branching model.
    

5.  Locate the option for branch deletion after pull request merge.
    
6.  Enable:Delete the source branch after pull request is merged
    

7.  Save the changes.
    
8.  Verify that newly merged pull requests automatically remove the source branch after successful merge completion.
    

Backout Plan

1.  Sign in to Bitbucket at [https://bitbucket.org](https://bitbucket.org/).
    
2.  Navigate to the target repository.
    
3.  Select Repository settings.
    
4.  Navigate to Branching model settings.
    
5.  Locate the branch deletion after merge configuration.
    
6.  Disable:Delete the source branch after pull request is merged
    

7.  Save the changes.
    
8.  Confirm that repository operations function as expected after the rollback.
    

Reference

-   [https://support.atlassian.com/bitbucket-cloud/docs/branching-models/](https://support.atlassian.com/bitbucket-cloud/docs/branching-models/)
    
-   [https://support.atlassian.com/bitbucket-cloud/docs/merge-a-pull-request/](https://support.atlassian.com/bitbucket-cloud/docs/merge-a-pull-request/)
    
-   [https://support.atlassian.com/bitbucket-cloud/docs/use-branch-permissions/](https://support.atlassian.com/bitbucket-cloud/docs/use-branch-permissions/)

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
