[Feature]: Automatically delete merged head branches
Preflight
- [x] I searched existing issues, discussions, and contributor tasks for this request.
- [x] This request and its attachments contain no credentials or private/internal material.
Request origin
Design or maintenance improvement
Problem or unmet outcome
Merged pull request branches can remain on the remote and accumulate as stale refs. This makes the branch list noisier and leaves routine cleanup to contributors or maintainers.
Use case
After an eligible pull request is merged, its head branch should be removed automatically without a separate cleanup command or privileged CI workflow.
Proposed outcome
Enable Settings → General → Pull Requests → Automatically delete head branches for this repository. GitHub should then remove eligible head branches after merge while continuing to respect branch protection rules and repository rulesets.
@huangruiteng, please consider enabling this repository setting.
LoopX area
Build, packaging, installer, or CI
Alternatives considered
- A custom GitHub Actions workflow with
contents: write: adds privileged CI and cleanup races that the native repository setting avoids. - Manual branch deletion: simple, but inconsistent and easy to forget.
Scope and non-goals
In scope:
- Enable the repository-level automatic branch-deletion setting.
- Keep the remote branch list clean after merges.
Out of scope:
- Deleting protected branches.
- Deleting branches owned by contributor forks.
- Adding a custom branch-cleanup workflow.
Reference: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-the-automatic-deletion-of-branches
Contribution
- [ ] I may be able to help design, implement, document, or validate this request.
这个我看目前是开启的