pullrequesttemplateexample.comReal pull request templates, read from the repos

CODEOWNERS file: where GitHub reads it, and which line wins

A CODEOWNERS file names who reviews changes to each path: one pattern per line, then its owners.

Updated December 3, 2026 · from GitHub's and GitLab's docs and 35 real files, read that day.

Where does the CODEOWNERS file go?

GitHub reads the first CODEOWNERS file it finds in .github/, the root or docs/, in that order, on the pull request's base branch, and the last matching line wins. Owners are requested automatically, but not on drafts, and a file over 3 MB is ignored. Each rule bites somewhere:

RuleGitHubWhere it bites
Locationfirst of .github/, root, docs/a second file elsewhere is ignored
Branchthe pull request's base branchowners on main don't apply to a pull request into gh-pages
Precedencethe last matching pattern winsa * line at the bottom overrides everything above it
Draftsowners are not requested on draft pull requeststhey are notified when it is marked ready
Sizeunder 3 MB, or it is not loadeduse wildcards to shrink it
Enforcement"Require review from Code Owners" in branch protectionwithout it the request is only a request

What is the CODEOWNERS syntax?

A pattern, then one or more owners on the same line: @user, @org/team or an email on the account. Patterns follow most gitignore rules. The usual cases:

A CODEOWNERS example

# Default owners for everything, first so later lines override it
*                    @acme/maintainers

# Every .ts file, anywhere
*.ts                 @acme/frontend

# A folder at the root, and everything under it
/infra/              @acme/platform @lee

# Protect the rules themselves
/.github/CODEOWNERS  @acme/maintainers

Three gitignore habits don't work in CODEOWNERS syntax: escaping a leading # with \, negating with !, and character ranges in [ ]. A line with bad syntax is skipped, and GitHub highlights the error when you open the file. Owners must have write access; a team must be visible and have write access itself.

Which line wins when two patterns match?

The last one. GitHub reads the file top to bottom and the last matching pattern decides the owners, so put the broad lines first and the narrow ones after. All 9 of the 35 files in our survey that have a catch-all * line put it first, where every later line can override it. Two owners for one pattern must share a line; a second line for the same pattern replaces the first.

Why wasn't a code owner requested?

  • The pull request is a draft. Mark it ready for review and the owners are notified; a clear pull request description tells them why before they open the diff.
  • The file isn't on the base branch. A CODEOWNERS on main does nothing for a pull request into another branch.
  • From a fork into your repository, the upstream base branch's file applies.
  • The owner lacks write access, or the team isn't visible. GitHub skips them.
  • The line has a syntax error, or the file is over 3 MB.

How do you require review from code owners?

Turn on "Require review from Code Owners" in the branch protection rule for the branch, or the same rule in a ruleset. Then a pull request touching an owned file needs an approval from one of its owners before it merges.

Code owners see the diff after it is written. On GitHub, a review app can read every push first and add its own required check beside them: IonWarp's IonWarp / Review check blocks the merge on an open P0 once it is required. It is GitHub only, $49 a month per workspace with 5 seats; the other review apps are compared on the home page.

How is GitLab's CODEOWNERS different?

GitHubGitLab
Search order.github/, root, docs/root, docs/, .gitlab/
Which branchthe pull request's base branchthe merge request's target branch
Tierspublic repos on Free; private repos on Pro, Team, EnterprisePremium and Ultimate
Required approvalbranch protection or a rulesetprotected branch with Code Owner approval on
Approvalsone owner's approval is enoughcan require several Code Owner approvals, or make them optional

GitLab CODEOWNERS files use the same "last match wins" rule and the same *-at-the-top advice (GitLab docs).

What do 35 real CODEOWNERS files look like?

We read .github/CODEOWNERS, CODEOWNERS and docs/CODEOWNERS in the 100 most-starred GitHub repositories on December 3, 2026, through GitHub's API. 35 have one: 29 in .github/, 6 in the root, none in docs/.

11 rulesthe median file, comments left out
3 ownersthe median number of distinct owners
13 of 35name a team (@org/team)
31 of 35also have a pull request template

The largest is godotengine/godot's: 457 rules in 38.8 KB, far under GitHub's 3 MB limit. Every row, with each file's link: codeowners-top-100-repos-2026-12-03.csv (CC BY 4.0). Owners are counted as distinct @ names and emails on rule lines.

CODEOWNERS questions

Does a code owner have to approve?

Only if branch protection or a ruleset requires it. Without "Require review from Code Owners", the owner is asked, not required.

Do all owners on a line have to approve?

No. GitHub's docs say an approval from any one of the owners listed for a file is enough.

Can I use an email instead of a username?

In most cases, if the email is on the person's GitHub account; not for managed user accounts. None of the 35 files in the survey do.

Is CODEOWNERS case-sensitive?

Yes. GitHub matches paths case-sensitively, even for teams on macOS, so the path must match the repository's casing.

Who should own the CODEOWNERS file itself?

Someone who can be trusted with review rules. GitHub's docs suggest putting it in .github/ and naming an owner for /.github/CODEOWNERS, so nobody can change the rules unreviewed.

How this page was checked

  1. GitHub: about code owners
  2. GitLab: Code Owners
  3. IonWarp docs on the check, and IonWarp pricing
  4. The 100-repository CODEOWNERS survey (CSV)

All read December 3, 2026.