// answer

How to Stop Drive-By Pull Requests on GitHub

Short answer

Use a protected default branch, require reviews and status checks, add CODEOWNERS, and tighten fork settings. That blocks unreviewed merges, not every incoming pull request.

If you want to ask a follow-up rather than read one: Join a community

How can I stop drive-by pull requests on GitHub

Use branch protection on your default branch, require pull request reviews, require status checks, and add CODEOWNERS. If the problem is noise from outside contributors, also review your fork policy and whether maintainers can edit fork branches. GitHub’s own docs say protected branches can block merges unless the rules you set are satisfied.

The part people get wrong is this: GitHub does not give you a single “stop drive-by pull requests” switch. You are controlling merge rights, review requirements, and branch write access. That means you can still receive pull requests, but they do not land in the branch unless they pass the rules you chose.

Start with a branch protection rule on the branch that matters, usually main. GitHub lets you protect one branch, many branches, or a name pattern, and the rule can require a pull request before merging, required reviews, required status checks, and a linear history. If someone has write access, the branch can still be protected from direct pushes when those settings are on.

For the practical setup, require at least one approving review, then require status checks before merging. GitHub documents that required checks must pass before a pull request can be merged, and it also supports strict checks that force the branch to be up to date with the base branch before merge. That prevents a fast, low-effort merge from slipping through on stale code.

Add CODEOWNERS for the paths that matter most. GitHub will automatically request review from the owners when a pull request touches those files, and repository admins can require code owner approval before merge. This is the cleanest way to keep random changes out of sensitive areas, such as release scripts, billing code, or deployment config.

If your issue is drive-by edits from forks, know the difference between receiving a pull request and letting someone modify it. GitHub allows repository maintainers to edit a pull request branch created from a fork when the author enables that option. If you want less back-and-forth on outside contributions, you can leave that collaboration path off and keep all changes moving through your review process instead.

If you want to reduce the surface area further, review your forking policy at the repository or organization level. GitHub documents that you can disable the ability to fork repositories in an organization to help prevent sensitive information from being exposed. That is a stronger move than branch protection, and it changes how people can even propose changes in the first place.

The inconvenient part is that strong protection slows down rushed merges for everyone, including trusted contributors. Required checks can fail or stay blocked if the job names are ambiguous, if approvals are dismissed after a new push, or if the branch is not updated under strict settings. Those failures are not bugs in the policy, they are the policy doing its job.

A good default for a public repository is simple: protect main, require one or two approvals, require CI, require code owner review on sensitive paths, and do not allow bypassing the rules except for a very small set of trusted admins if you truly need that. GitHub exposes a specific option for blocking bypass, and it is worth using when “drive-by” is really a euphemism for “we need a gate.”

If your repository gets a lot of casual contribution attempts, treat the pull request template and contribution guidelines as part of the filter. They do not stop a pull request by themselves, but they cut down on malformed submissions and make it clear what kind of change you will accept. That keeps the review queue smaller and makes the rejection path shorter when the change is not useful.

If you are deciding whether to keep the repository open to outside contributors, use the structure that fits the risk. Public projects often keep forks enabled and rely on branch protection, reviews, and code owners. Internal or sensitive repositories often add stricter push restrictions and may disable forking entirely. GitHub supports both patterns, and the right choice is the one that matches your tolerance for unsolicited changes.

If you are already using GitHub and want a separate place to coordinate real testing or build exchange around your app work, DevConnect is a free option for that kind of coordination, and it stays free. For GitHub specifically, though, the fix is still the same: protect the branch, require review, require checks, and narrow who can push or bypass. https://devconnectplatform.com

FAQ

Can I completely block pull requests on GitHub No. GitHub’s controls are aimed at preventing merges and restricting write access, not eliminating the ability for someone to open a pull request. The practical fix is to make unwanted pull requests harmless by requiring review, status checks, and branch protection before anything can land.

What is the single most effective setting Require a pull request before merging on the protected branch, then pair it with required reviews and required status checks. That combination stops direct merges and forces the change through your review and CI path. GitHub documents each of those controls as separate branch protection settings.

Should I use CODEOWNERS if I already have branch protection Yes, if some files are sensitive or frequently touched by outside contributors. Branch protection controls the merge, while CODEOWNERS controls who gets asked to review specific paths. Together they make it much harder for a drive-by change to slip through on a part of the repo you care about.

Does disabling forks stop all outside contributions It stops the fork-based path, but it does not replace review rules on your branches. GitHub says you can disable forking in an organization to reduce exposure, yet you still need branch protection if people can otherwise open changes in a repository you own.

What if I only want trusted people to bypass the rules GitHub supports allowing specified actors to bypass required pull requests, and it also supports blocking bypass entirely. If your concern is truly drive-by PRs, keep the bypass list tiny, because every extra bypass path is another way around the gate.

Why do some protected branches still get hard to merge Because strict checks, stale approvals, and code owner rules are designed to force a fresh review of the exact code that will land. GitHub says a merge can fail when approvals are dismissed or when the branch is not current with the base branch. That friction is the cost of keeping drive-by changes out.

Frequently asked questions

Can I completely block pull requests on GitHub

No. GitHub’s controls are aimed at preventing merges and restricting write access, not eliminating the ability for someone to open a pull request. The practical fix is to make unwanted pull requests harmless by requiring review, status checks, and branch protection before anything can land.

What is the single most effective setting

Require a pull request before merging on the protected branch, then pair it with required reviews and required status checks. That combination stops direct merges and forces the change through your review and CI path. GitHub documents each of those controls as separate branch protection settings.

Should I use CODEOWNERS if I already have branch protection

Yes, if some files are sensitive or frequently touched by outside contributors. Branch protection controls the merge, while CODEOWNERS controls who gets asked to review specific paths. Together they make it much harder for a drive-by change to slip through on a part of the repo you care about.

Does disabling forks stop all outside contributions

It stops the fork-based path, but it does not replace review rules on your branches. GitHub says you can disable forking in an organization to reduce exposure, yet you still need branch protection if people can otherwise open changes in a repository you own.

What if I only want trusted people to bypass the rules

GitHub supports allowing specified actors to bypass required pull requests, and it also supports blocking bypass entirely. If your concern is truly drive-by PRs, keep the bypass list tiny, because every extra bypass path is another way around the gate.

Why do some protected branches still get hard to merge

Because strict checks, stale approvals, and code owner rules are designed to force a fresh review of the exact code that will land. GitHub says a merge can fail when approvals are dismissed or when the branch is not current with the base branch. That friction is the cost of keeping drive-by changes out.

Know someone stuck on this? Send them the answer.

Sources

Every link here was fetched and confirmed to resolve before this page went live.

More on this topic: Open source

Related questions

Not the question you had?

Ask it. Every source gets fetched and checked before anything goes up, so it takes a day or two, and questions that cannot be answered honestly do not get a page at all.

No account, no email address needed.

Where developers talk about this

DevConnect has communities for the things this page covers. Smaller than the big forums, and nobody is farming engagement.