You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh merge pr -s -d does not delete PR branch if on a fork different from base branch #2860
❯ gh --version
gh version 1.5.0 (2021-01-21)
https://github.com/cli/cli/releases/tag/v1.5.0
When merging a PR from a branch on a different fork (than the base branch) with squash and delete enabled via the gh cli causes the PR to be merged with a squashed commit, but the source branch is not deleted either locally or remotely.
Steps to reproduce the behavior
Create a PR from a branch on a fork different from the base branch.
Merge the PR via the cli with squash and delete-branch enabled: gh merge pr -s -d xx
The PR should get merged and the source branch deleted locally and remotely.
Expected vs actual behavior
Expected result:
The PR should get merged and the source branch deleted locally and remotely.
Actual result:
The PR gets merged but the source branch are not deleted locally or remotely.
❯ gbd feature/updates
warning: deleting branch 'feature/updates' that has been merged to
'refs/remotes/origin/feature/updates', but not yet merged to HEAD.
Deleted branch feature/updates (was 0d02dc6).
❯ gp origin :feature/updates To github.comcast.com:VRanga000/pulumi.git
- [deleted] feature/updates
We currently avoid trying to delete a branch if the PR is cross-repo because an OSS maintainer who is merging cross-repo PRs typically doesn't have permissions to delete the branch in a fork that they don't own. However, we could also try to detect branch permissions and allow you to delete your branch even for PRs that are cross-repo. 👍
Activity
mislav commentedon Jan 27, 2021
Thank you for reporting!
We currently avoid trying to delete a branch if the PR is cross-repo because an OSS maintainer who is merging cross-repo PRs typically doesn't have permissions to delete the branch in a fork that they don't own. However, we could also try to detect branch permissions and allow you to delete your branch even for PRs that are cross-repo. 👍
TyceHerrman commentedon Aug 10, 2026
Related GitHub product-feedback discussion: community#201691
requests an opt-in way to automatically delete a source branch in a contributor's fork after its pull request is merged into the upstream repository