CODEOWNERS

On GitHub, a CODEOWNERS file maps repository file patterns to the people or teams responsible for reviewing changes to those files.

Who gets asked to review?

GitHub uses CODEOWNERS to find reviewers for changed files. Requiring their approval before a merge takes an additional repository protection setting. Having an ownership file alone does not enforce review.

When a matching pattern names several owners, one owner’s approval can satisfy the code-owner requirement. Listing two people does not automatically require both to approve.

Which ownership rule wins?

GitHub uses the CODEOWNERS file on the pull request’s base branch. If several patterns match a file, the last matching pattern takes precedence. Order therefore matters: a later, narrower entry can replace the default owners for part of the repository.

Owners also need the required repository access. GitHub skips invalid syntax and does not assign nonexistent owners or those with insufficient access. Check the file’s reported errors when an expected review request is missing.

Give the ownership file itself an owner. Changing it can change who reviews future work, which makes it part of the access review discussed in the maintainer handoff guide.

CODEOWNERS governs review routing. The workflow approval article covers the separate controls needed when contributed code runs in automation.

Sources

See it in practice