Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

Reject branch deletion if corresponding PR is open #1723

Open

Description

@sideshowbarker

GitHub should provide a per-repository branch-protection option for rejecting deletion of a branch if there’s a pull request still open which is based on that branch.

Rationale: With git, it’s unfortunately quite easy/common in practice to make the mistake of running a command such as git push --prune --all while having unintentionally omitted the name of a particular remote — in which case the branches will be pruned for the origin remote (or whatever the default remote is for the repo) rather than whatever other remote the person running that command actually intended but inadvertently forgot to include in the command.

For a repo with a lot of open branches and open pull requests, the consequences of having run an inadvertent git push --prune --all command like that can be a lot of work to deal with — since it’ll have the effect of both deleting all the branches while also closing all their associated pull requests. It can a lot of time/effort to recover all the branches and reopen all the PRs.

So it’d be great to have some way to protect a repo against this particular git footgun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions