Description

Ensure the repository is configured to automatically delete the head branch of a pull request once it has been merged into the base branch.

Rationale

Merged feature branches that are never cleaned up accumulate over time, making the repository harder to navigate and increasing the chance that a developer accidentally continues work on, or pushes to, a stale branch. Automatic deletion keeps the branch list current and reduces the surface of forgotten branches.

Impact

  • Automatically removes merged feature branches, keeping the repository clean

  • Reduces the risk of developers accidentally continuing work on, or pushing to, stale branches

  • Lowers the number of branches that must be tracked and secured

  • Simplifies branch protection scoping and review

Default Value

By default, GitHub does not automatically delete head branches after a pull request is merged.

Pre-Requisites

  • Admin access to the repository

Test Plan

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. On the General page, scroll to the Pull Requests section.

  5. Verify that Automatically delete head branches is checked.

  1. If it is unchecked, follow the implementation steps.

Implementation Steps

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. On the General page, scroll to the Pull Requests section.

  1. Select Automatically delete head branches.

  1. The change is saved automatically.

Backout Plan

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. On the General page, scroll to the Pull Requests section.

  5. Deselect Automatically delete head branches.

Reference