🔀 Git & GitHub Intermediate

What is the CODEOWNERS file in GitHub?

Why Interviewers Ask This

This question targets practical, hands-on experience with Git & GitHub. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.

Answer

The CODEOWNERS file (located at /.github/CODEOWNERS, /CODEOWNERS, or /docs/CODEOWNERS) specifies which team members are responsible for specific files or directories in the repo. When a PR modifies a file with a defined owner, GitHub automatically requests a review from those owners. Syntax: same as .gitignore patterns, followed by GitHub usernames or team names. Examples: * @default-owner — default owner for all files; src/auth/ @security-team — auth directory requires security team review; *.sql @data-team — all SQL files require data team; package.json @frontend-lead — specific file. Multiple owners: src/api/ @alice @backend-team — any one of them can approve. Last matching rule wins. Combined with branch protection "Require review from Code Owners": no PR can merge unless all appropriate code owners have approved changes to their files. Benefits: ensures domain experts review changes to critical code (security, database schema, API contracts), reduces oversight of critical areas, documents implicit code ownership. Update as team structure and ownership evolves.

Pro Tip

If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.