One Horizon
    • Log inJoin Beta
    HomePricingChangelogLog inSign upBlogDocsTerms of UsePrivacy Policy

    © 2026 One Horizon. All rights reserved

    FacebookInstagramThreadsXRedditDiscordTikTokYouTubeMedium


    Back to blogs

    How to Use GitHub CODEOWNERS to Prevent Merge Conflicts

    Tijn van Daelen•January 22, 2026•7 Min Read
    How to Use GitHub CODEOWNERS to Prevent Merge Conflicts

    You know the drill. A pull request sits waiting for reviews. Three engineers touch the same shared config file across different features. By the time someone merges, Git throws up a wall of red conflict markers. What should have been 30 minutes of work becomes half a day of manual conflict resolution.

    Teams accept this as "just how Git works." But most merge conflicts are not git problems. They are governance problems.

    Poor ownership boundaries force unrelated changes through the same chokepoints. No one knows who should coordinate shared files. Reviews go to the wrong people, or no one at all. GitHub CODEOWNERS fixes this by making ownership explicit and enforceable.1

    This guide shows you how to design CODEOWNERS that actually prevents conflicts, not just documents who to ping after they happen.


    The real cause of merge conflicts

    Merge conflicts happen when multiple changes target the same lines of code without coordination. Sound obvious? Most teams miss the deeper pattern.

    Pattern 1: Shared file magnets
    config/app.yml, types/global.ts, middleware/auth.js - files everyone touches become conflict central. Three squads all need config tweaks in the same sprint. Boom, conflicts.

    Pattern 2: No clear "who coordinates"
    When backend-team owns the API but platform-team owns shared middleware, who talks first? Without clear rules, parallel work collides.

    Pattern 3: Risky changes hide in routine reviews
    Billing logic, auth middleware, and database migrations get the same "two approvals from anyone" treatment as copy changes. Either everything slows down, or risky work slips through.

    CODEOWNERS solves all three by mapping files to responsible teams and automatically routing reviews. More importantly, it makes teams think twice before touching someone else's turf.


    What CODEOWNERS actually does (and why it prevents conflicts)

    A CODEOWNERS file contains simple pattern → owner rules:

    # High risk areas/services/billing/ @payments-team/services/auth/ @security-team
    # Team domains  /apps/web/ @frontend-team/apps/api/ @backend-team
    # Shared patterns**/*.sql @data-team

    When a pull request touches those paths, GitHub automatically requests reviews from the listed owners.

    Place the file in repo root, docs/, or .github/ (GitHub checks in that order). Connect it to branch protection rules, and those owners must approve before merge.2

    The conflict prevention magic: Clear ownership encourages decomposition. Teams see "this touches payments code" and either coordinate upfront or extract their change into a non-conflicting shape. Conflicts become rare signals of architectural problems, not daily fire drills.


    Designing conflict-proof ownership rules

    Bad CODEOWNERS creates bureaucracy. Good CODEOWNERS mirrors your architecture.

    Rule 1: Order matters (most specific first)

    GitHub matches rules top-to-bottom, last match wins. Wrong order silently shifts ownership:

    # WRONG - backend-team catches everything/apps/** @backend-team/apps/api/** @api-squad  # Never matches!
    # CORRECT - specific rules last/apps/** @backend-team/apps/api/** @api-squad  # Wins for API paths

    Rule 2: Minimize overlap

    Each team gets clean boundaries. Overlap forces coordination that nobody plans for:

    # Clean boundaries/apps/product1/ @squad-alpha  /apps/product2/ @squad-beta/libs/shared/ @platform-team
    # Overlap disaster  **/*.ts @frontend-team/apps/** @product-teams  # Fights above rule

    Rule 3: Protect the hotspots

    Your conflict-prone files need explicit owners:

    # These files cause 80% of conflictsconfig/app.yml @platform-teammiddleware/ @platform-team  migrations/ @data-team

    Production CODEOWNERS example

    For a typical product engineering repo (web app, API, infra):

    # See docs/ownership.md for team responsibilities
    # CRITICAL INFRA (narrowest ownership)infrastructure/ @platform-teammigrations/ @data-teamservices/billing/ @payments-teamservices/auth/ @security-team
    # PRODUCT DOMAINS (team autonomy)apps/web/ @frontend-teamapps/api/ @backend-teamapps/mobile/ @mobile-team
    # CROSS-CUTTING (file type patterns)**/*.sql @data-team**/*.yml @platform-teamdocs/ @docs-team
    # FALLBACK (avoid if possible)* @backend-team

    Commit this to .github/CODEOWNERS. Push to main.1


    Enforcing with branch protection

    CODEOWNERS without enforcement is a polite suggestion. Connect it to protected branches:

    1. Repository Settings → Branches → Add rule
    2. Branch pattern: main
    3. Check: "Require review from Code Owners"2
    4. Check: "Require approvals: 1"
    5. Check: "Require status checks" (your CI)

    Now no one merges billing changes without payments-team approval. Conflicts in hot paths become impossible without coordination.


    Common anti-patterns that create conflicts

    1. The "everyone owns everything" rule

    * @all-engineers

    Every PR pings 20 people. Nobody feels responsible. Conflicts still happen.

    Fix: Explicit domain ownership + narrow fallbacks.

    2. Catch-all teams without substructure

    * @backend-team

    30 engineers get pinged for typos in docs. Real ownership gets lost in noise.

    Fix:

    docs/ @docs-teamapps/ @backend-team

    3. Missing high-risk paths

    No rules for config/, migrations/, shared middleware. Everyone touches them freely.

    Fix: Explicit hotspot protection (see production example above).


    Rollout plan (zero disruption)

    1. Week 1: Visibility only
      Add CODEOWNERS file. Reviews auto-request but aren't required. Watch who gets pinged.

    2. Week 2: Protect main branch
      Enable "Require review from Code Owners" on main only. Feature branches stay fast.

    3. Week 3: Measure + iterate
      Check conflict rates on owned paths. Adjust rules based on real usage patterns.

    4. Document ownership model
      Point to docs/ownership.md explaining team boundaries and escalation paths.


    Measuring success

    Track these before/after:

    • Conflict rate: GitHub Insights → Pulled Requests → filter by conflicting merges
    • Review time: Average days from PR open → merge for owned vs unowned paths
    • Reviewer load: Who gets most requests? Adjust rules to balance.

    Teams using structured ownership see 40-60% fewer conflicts in shared paths.3 Reviews route to the right people automatically.


    Limitations (and complements)

    CODEOWNERS excels at file-based ownership. It misses:

    • Why changes exist (PR context, ticket links)
    • When risky changes cluster (sprint boundaries, deploys)
    • Who is overloaded (reviewer capacity)

    This creates gaps where conflicts still sneak through despite good rules.


    One Horizon: Ownership + full context

    CODEOWNERS gives you mechanical enforcement: right reviewers, protected paths, no merge without approval.

    One Horizon adds the missing layer: connecting those ownership rules to the full delivery context.

    PRs link to Linear/Jira tickets, Slack discussions, calendar blocks, and goals. Engineering leaders see:

    • Which owned areas have collision risk this sprint
    • Reviewer overload before queues explode
    • How ownership changes map to architectural drift

    Instead of "payments-team must approve billing changes," you get "payments-team must approve these 3 billing PRs connected to Q1 pricing objectives, blocked by @sarah's vacation - escalate to @deputy?"

    GitHub handles the rules. One Horizon handles the coordination that makes rules actually work.

    Configure your CODEOWNERS. Protect your branches. Let One Horizon surface the real risks before they become red diffs.

    Sign up


    Footnotes

    1. GitHub Docs. "About code owners and code owners file location." https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners ↩ ↩2

    2. GitHub Docs. "Managing protected branches and requiring code owner reviews." https://docs.github.com/en/repositories/configuring-branches-and-merges/managing-protected-branches/about-protected-branches ↩ ↩2

    3. Stack Overflow Blog. "What makes a good code review policy?" https://stackoverflow.blog/2024/06/12/what-makes-a-good-code-review-policy/ ↩


    Share this article


    Related Posts

    Branch Strategies That Actually Work for Growing GitHub Teams

    Branch Strategies That Actually Work for Growing GitHub Teams

    Branch chaos is not a developer problem, it is a systems problem. The right GitHub branch strategy turns random conflicts and broken pipelines into a predictable shipping rhythm.

    Tijn van Daelen•January 23, 2026•12m
    Mastering GitHub: Essential Tips for Modern Development Teams

    Mastering GitHub: Essential Tips for Modern Development Teams

    Discover how to leverage GitHub's full potential with advanced techniques for workflows, code reviews, and collaboration that will transform your development process and increase team productivity.

    Alex van der Meer•April 7, 2025•14m