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.

  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.

  2. Navigate to the target project.

  3. Select Settings → Merge requests.

           

  1. Locate the Merge options section.

  2. Check "Enable 'Delete source branch' option by default".

  1. Click Save changes.


Backout Plan:

  1. Sign in to GitLab at https://gitlab.com.

  2. Navigate to Settings → Merge requests.

  1. Locate the Merge options section.

  2. Uncheck "Enable 'Delete source branch' option by default".

  1. Click Save changes.

  2. Confirm that project operations function as expected after the rollback.


Reference: