All docs

People and access

Branch rules and code owners

Protect branches, decide what a change needs before it merges, require checks and signed commits, and name code owners.

Branch rules are in a repository's Settings → Branch rules, for people with the maintain role or above. They're enforced on every push, web edit and submit, and a refused push says why and how to send the work for review instead.

Approvals needed to submit

Settings → General → Approvals needed to submit sets how many approvals a change needs by default (one, from someone other than its author). A branch rule can ask for more on its branches.

Protect a branch

Type a name or pattern in Protect branches matching and add the rule. * matches within one part of a name and ** across parts: release/* matches release/1.0, and main matches only main. Each rule has:

  • Changes must go through review (no direct pushes): nobody pushes to the branch; everything arrives through review.
  • Direct pushes need a role, when review isn't required: say, maintain, so only maintainers can push straight to it.
  • Approvals needed: the repository default, or more.
  • Allow force pushes and Allow deleting matching branches: both off unless you tick them.

Remove rule deletes it. A branch matched by more than one rule gets the strictest of each setting.

Completion rules

Under Before a change can merge, each rule can also ask that:

  • Discussions someone is waiting on must be resolved;
  • "Ask for changes" holds the change until that reviewer approves;
  • Everyone asked to review must approve;
  • Code owners must approve their files (from the CODEOWNERS file on this branch);
  • Commits must be signed with a verified key, refusing pushes otherwise (see Signed commits);
  • named checks pass, such as ci/test, lint (see CI and checks).

On a branch no rule covers, discussions someone is waiting on and "ask for changes" still hold a change.

Code owners

A CODEOWNERS file names who owns which files. Put it at the root, or in .fettlecode/, .github/ or docs/. Each line is a pattern and its owners: @username, @org/team, or an email address.

# Everything, unless a later line says otherwise
*                 @priya

# The web app belongs to the web team
/apps/web/        @wren/web

# Any SQL file, anywhere
*.sql             @tom [email protected]
  • Patterns work like .gitignore: *.sql matches at any depth, docs/ matches a docs folder anywhere, and a pattern starting with / (or with a slash in the middle) starts at the root.
  • The last matching line wins. A line with a pattern and no owners means nobody in particular owns those files.
  • It's read from the branch the change is going into, not from the change, so a change can't make its author an owner.

Each change shows its owners and whether they've approved. With Code owners must approve their files ticked, it can't merge until they have.

The audit log

Rule changes, direct pushes, force pushes and submits are recorded in the repository's audit log.