Accidental Remote Branches Created on Github

A branch containing the D112590 patch was accidentally pushed to GitHub: https://github.com/llvm/llvm-project/tree/efb284c07e

In the past couple of weeks, this also happened for
https://reviews.llvm.org/D107347
and
https://reviews.llvm.org/D108319

This seems to be happening a lot recently. Is there a problem with the instructions to commit patches?

This happening was actually a big fear for me when I got commit access, especially since I'm working on a fork for my hobby osdev project, not at all ready for upstreaming it - one wrong git push away

Seeing this happening to other people is a bit of a relief

Is it possible to configure GitHub to forbid that? Like everything except the normal branches being protected from pushes?

Mara

I’ve done this once or twice accidentally in the past (and noticed immediately/deleted). It is very easy to do :confused:

Unfortunately not: there is a “branch protection” mechanism on GitHub but it applies only to branches after they are created as far as I know.

Pushing a random branch has little consequence, it is easy to delete: pushing the wrong kind of things to the main branch would be more annoying and hard-to-impossible to recover from.

Cheers,

Unfortunately, GitHub does not allow this kind of "protection". Only
existing branches can be protected from pushes.
We already had such issues in the past when the outdated "master"
branch was pushed into the repo after the "master => main" transition.
We reported the issue to GitHub ~year ago, but this might be included
into their roadmap for 2023 or so.

We've been told that the "workaround" is an action that removes all
non-known branches, however, I'm a little bit hesitant on having such
kind of powerful automation, that could remove something from the
repo.

What about the action opening an issue for the bad branch and when that
issue is 7 days old without someone closing it ("that branch is ok"),
another (periodic) action then removes the branch?

That would do the expected thing automatically, but with a visible delay
to make it less dangerous. Also, the branches would only be lost on
GitHub and still be available on the computer someone pushed them from -
not perfectly safe, but better than "automatically lost forever".

Of course only viable once issues are migrated to Github, otherwise it's
chaos the people doing that migration surely wouldn't like ^^'

This is one of the reasons everyone having write access is not a great workflow. For my other projects I set the push URL for upstream to DISABLED and then have a custom “sudo” git command that resets the URL. This doesn’t work well with arc though, so I don’t use it for LLVM. If we switched to GItHub PRs, then everything could be forced to go through a PR, but this requires additional automation (the only way for someone to merge PRs is also for them to have write access).