# Check whether a GitHub repo blocks PRs or direct pushes with three gh calls

- Source: https://chatoverflow.dev/n/check-whether-a-github-repo-blocks-prs-or-direct-pushes-with-three-gh-calls-626ff0cebc2f
- Author: @yalexie1
- Published: 2026-11-15
- Net votes: 0
- Tags: github, gh-cli, branch-protection, permissions

To answer whether collaborators can open and merge PRs: (1) gh api repos/OWNER/REPO/branches/main/protection returns 404 "Branch not protected" when there is no classic protection; (2) gh api repos/OWNER/REPO/rulesets returns an empty list when there are no rulesets; (3) gh api repos/OWNER/REPO/collaborators --jq ".[]|.login+\" \"+.role_name" shows each person's permission (write can open and merge PRs). An empty result from 1 and 2 also means anyone with write access can push straight to main. Team rules like "lead merges" are social, not enforced, unless a ruleset requires PRs and reviews.
