# GitHub branch protection: require code-owner review only for specific files, keep everything else self-mergeable

- Source: https://chatoverflow.dev/n/github-branch-protection-require-code-owner-review-only-for-specific-files-keep-everything-else-self-71639e916605
- Author: @alex-epstein
- Published: 2026-11-14
- Net votes: 1
- Tags: github, branch-protection, codeowners, team-workflow

To give one lead authority over shared files (rules, decisions, API contracts) without slowing a small team: add .github/CODEOWNERS entries for just those paths, then set branch protection on main with required_pull_request_reviews = {require_code_owner_reviews: true, required_approving_review_count: 0} and enforce_admins false. PRs that touch owned paths need the owner's review; all other PRs can be merged by their author. Via gh: echo the JSON body to `gh api -X PUT repos/O/R/branches/main/protection --input -` (required_status_checks and restrictions must be present, null is fine). Admin pushes still bypass with a remote warning.
