How to Require Code Owner Reviews With CODEOWNERS
CODEOWNERS maps paths to owners, and branch protection can require an approving review from an owner of every changed path.
Create .github/CODEOWNERS mapping globs to teams or users, then enable "Require review from Code Owners" so a pull request touching those paths needs owner sign-off.
Steps
- Create
.github/CODEOWNERSmapping path globs to owners. - Enable "Require review from Code Owners" in branch protection.
- Owners are requested automatically on matching pull requests.
CODEOWNERS
Terminal
# .github/CODEOWNERS
* @org/maintainers
/frontend/ @org/web-team
/infra/ @org/platform
*.sql @org/dbaRequire it
Settings
Settings > Branches > main
[x] Require a pull request before merging
[x] Require review from Code OwnersGotchas
- The last matching pattern in CODEOWNERS wins, so order specific rules after broad ones.
- An invalid CODEOWNERS entry is ignored silently; check the Owners tab renders it as expected.
Related guides
How to Require Pull Request Reviews With Branch ProtectionRequire a minimum number of approving reviews before merge with a GitHub branch protection rule, and combine…
How to Dismiss Stale Reviews When New Commits Are PushedAutomatically invalidate approving reviews when a pull request gets new commits, using the dismiss stale revi…
How to Configure Bypass Lists for Branch ProtectionGrant specific apps, teams, or roles the ability to bypass a GitHub ruleset or branch protection rule, so aut…