Sub topic 6
Leaving paths unowned and resetting ownership
This chapter assumes you can write CODEOWNERS patterns and know that the last matching pattern wins. It covers what happens when no owner applies to a path, and how to remove ownership on purpose.
What "unowned" means
A path is unowned when no pattern in the CODEOWNERS file matches it, or when the last matching pattern lists no owners. GitHub requests no code owner review for an unowned file. If the pull request touches only unowned files, code owner review is not required at all.
There are two ways to reach that state:
- Never matched. The file has no fallback
*line, and no other pattern covers the path. - Reset on purpose. A later pattern matches the path and lists no owners.
Resetting ownership with an empty pattern
Because the last match wins, a pattern with no owners overrides every earlier match. Use this for files nobody should have to review, such as generated output.
# .github/CODEOWNERS
* @example-org/maintainers
/apps/web/ @example-org/web-team
/apps/web/generated/Here is how three paths resolve:
| Path | Last matching pattern | Owner |
|---|---|---|
| `README.md` | `*` | `@example-org/maintainers` |
| `apps/web/src/index.js` | `/apps/web/` | `@example-org/web-team` |
| `apps/web/generated/schema.js` | `/apps/web/generated/` | none |
Unowned is not the same as blocked
Leaving a path unowned does not stop the pull request from merging. It only means CODEOWNERS adds no requirement for that path. Other rules still apply, such as the required approving review count from branch protection. A pull request that touches only generated files can still need one ordinary approval.
When to leave paths unowned
Reset ownership when review adds no value:
- Generated code, lock files, or build output that humans do not edit.
- Directories where a broad pattern would otherwise pull in a team that has no stake in them.
Be careful with the opposite case. Without a fallback * line, any new top-level directory is unowned until someone adds a pattern for it. If you want every change to have an owner, keep a fallback line first in the file and let narrower patterns override it.
Common mistakes
- Placing the reset pattern too early. If a broader pattern appears below the empty one, the broader pattern wins and the files get owners again.
- Expecting a reset to inherit a parent's owners. Ownership is not inherited. The empty pattern removes owners entirely.
- Assuming "no owner" means "anyone can merge unreviewed". Required approval counts still apply.
Exercise
A CODEOWNERS file contains /docs/ @example-org/docs-team, followed later by /docs/archive/ with no owners. A pull request changes docs/guide.md and docs/archive/2019.md. Which owners are requested, and what happens if the pull request changed only docs/archive/2019.md?
Show answer
@example-org/docs-team is requested for docs/guide.md only, because docs/archive/2019.md is reset to no owner by the later empty pattern. If only the archive file changed, no code owner review is requested or required. Any required approving review count from branch protection still applies.