# Ensure source branches are deleted after merge request merge

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

Description:

This check verifies that a GitLab project is configured to automatically delete the source branch once a merge request is merged into the target branch. This setting keeps the repository clean by removing short-lived feature branches after they've served their purpose, rather than leaving them to accumulate indefinitely.

  

Rationale:

Retaining merged source branches indefinitely leads to repository clutter, making it harder for contributors to identify active work versus stale, already-merged branches. Automatically deleting source branches after merge improves repository hygiene, reduces confusion, and lowers the risk of someone accidentally continuing work on a branch that has already been integrated.

  

Impact:

-   Remove the source branch immediately after a merge request is merged.
    
-   Require contributors to create a new branch if further work related to the same feature is needed.
    
-   Improve repository cleanliness and reduce clutter from stale branches.
    
-   Have no effect on the merge request's history or the target branch's commit history.
    

  

Default Value:

Disabled By default, GitLab projects do not automatically delete source branches after a merge request is merged. Default setting: remove\_source\_branch\_after\_merge: false

  

Pre-Requisites:

-   Maintainer or Owner access to the project
    
-   An existing GitLab project
    

  

Test Plan:

1.  Sign in to GitLab at [https://gitlab.com](https://gitlab.com/).
    
2.  Navigate to the target project.
    
3.  Select Settings → Merge requests.
    
4.  Locate the Merge options section.
    
5.  Verify that "Enable 'Delete source branch' option by default" is checked.
    

  

Implementation Steps:

1.  Sign in to GitLab at [https://gitlab.com](https://gitlab.com/).
    
2.  Navigate to the target project.
    
3.  Select Settings → Merge requests.
    

4.  Locate the Merge options section.
    
5.  Check "Enable 'Delete source branch' option by default".
    

6.  Click Save changes.
    

  

Backout Plan:

1.  Sign in to GitLab at [https://gitlab.com](https://gitlab.com/).
    
2.  Navigate to Settings → Merge requests.
    

3.  Locate the Merge options section.
    
4.  Uncheck "Enable 'Delete source branch' option by default".
    

5.  Click Save changes.
    
6.  Confirm that project operations function as expected after the rollback.
    

  

Reference:

-   [https://docs.gitlab.com/ee/user/project/merge\_requests/reviews/index.html](https://support.icompaas.com/home/icsys-026/support/support_web/%5Bobject%20Object%5D)
    
-   [https://docs.gitlab.com/ee/api/projects.html](https://support.icompaas.com/home/icsys-026/support/support_web/%5Bobject%20Object%5D)
    
-   [https://docs.gitlab.com/ee/user/project/repository/branches/index.html](https://support.icompaas.com/home/icsys-026/support/support_web/%5Bobject%20Object%5D)

## 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.
