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
Sign in to GitHub at https://github.com.
Select the relevant repository.
Click Settings.
On the General page, scroll to the Pull Requests section.
Verify that Automatically delete head branches is checked.
If it is unchecked, follow the implementation steps.
Implementation Steps
Sign in to GitHub at https://github.com.
Select the relevant repository.
Click Settings.
On the General page, scroll to the Pull Requests section.
Select Automatically delete head branches.
The change is saved automatically.
Backout Plan
Sign in to GitHub at https://github.com.
Select the relevant repository.
Click Settings.
On the General page, scroll to the Pull Requests section.
Deselect Automatically delete head branches.
Reference