How to fix remote: error: GH006: Code owners review required in Git

GitBEGINNERMEDIUMUpdated Dec 6, 2025· 224 views

This error occurs when you try to push or merge changes to a protected branch that requires approval from designated code owners. The branch protection rules enforce that any pull request modifying code owned by specific individuals or teams must be approved by those code owners before merging.

Quick fix

Fixes GH006

# Create a new branch for your changes
git checkout -b feature/my-changes

# Make your changes and commit
git add .
git commit -m "Your descriptive commit message"

# Push the feature branch
git push -u origin feature/my-changes
  1. Create a pull request instead of pushing directly
  2. Identify which code owners need to approve
  3. Request review from the designated code owners
  4. Address review feedback and get approval
git — error
# Create a new branch for your changes
git checkout -b feature/my-changes
# Make your changes and commit
git add .
git commit -m "Your descriptive commit message"
# Push the feature branch
git push -u origin feature/my-changes
remote: error: GH006: Code owners review required

What this error means

The "GH006: Code owners review required" error indicates that GitHub's branch protection rules are blocking your push or merge operation. This happens when the target branch has the "Require review from Code Owners" protection rule enabled, and your changes affect files that have designated code owners who haven't approved the changes yet. Code owners are defined in a CODEOWNERS file within the repository, which specifies which users or teams are responsible for reviewing changes to specific files or directories. When you modify files covered by the CODEOWNERS file, GitHub automatically requests reviews from the designated owners. This protection mechanism ensures that changes to critical parts of the codebase are reviewed by the people most familiar with that code before being merged. It's a common practice in enterprise environments and open-source projects to maintain code quality and security. The error typically appears when: - **Pushing directly to a protected branch**: You're trying to push commits directly instead of using a pull request - **Merging without required approvals**: The pull request hasn't received approval from the designated code owners - **Force pushing to a protected branch**: Even with write access, force pushes may be blocked without code owner approval

Typical symptoms

  • Push to a protected branch fails with 'remote: error: GH006: Protected branch update failed'
  • Merge button is disabled in the GitHub pull request interface
  • GitHub shows 'Review required from code owners' message on the PR
  • CI/CD pipelines fail at the push or merge step with GH006 error
  • Git push returns 'Changes must be made through a pull request'
  • Pull request shows pending review status from specific team or user

Common causes

  1. Branch protection requires code owner approval and you haven't received it yet
  2. You're trying to push directly to a protected branch instead of using a pull request
  3. The CODEOWNERS file designates specific reviewers for the files you modified
  4. A code owner previously requested changes and hasn't approved the updates
  5. Your changes affect multiple code owner domains and not all have approved
  6. The code owner who needs to approve is unavailable or hasn't reviewed
  7. You're trying to bypass branch protection with insufficient permissions
  8. A required code owner was recently removed from the repository

How to fix "remote: error: GH006: Code owners review required"

1Create a pull request instead of pushing directly

Protected branches with code owner requirements don't accept direct pushes. You must use the pull request workflow:

bash
# Create a new branch for your changes
git checkout -b feature/my-changes

# Make your changes and commit
git add .
git commit -m "Your descriptive commit message"

# Push the feature branch
git push -u origin feature/my-changes

Then go to GitHub and create a pull request from your feature branch to the protected branch. GitHub will automatically request reviews from the appropriate code owners based on the CODEOWNERS file.

2Identify which code owners need to approve

Check your pull request to see who needs to approve the changes:

1. Open your pull request on GitHub
2. Look at the "Reviewers" section in the sidebar
3. GitHub shows which code owners are required and their review status
4. The CODEOWNERS file determines who owns which files

To view the CODEOWNERS file:

bash
# CODEOWNERS is typically in one of these locations:
cat .github/CODEOWNERS
cat CODEOWNERS
cat docs/CODEOWNERS

Example CODEOWNERS syntax:

bash
# Global owners (review everything)
* @default-reviewer

# Specific directory ownership
/src/api/ @backend-team
/src/frontend/ @frontend-team

# Specific file ownership
/security/ @security-team @lead-developer

Understanding the CODEOWNERS file helps you identify who to contact for approval.

3Request review from the designated code owners

Once you've identified the required reviewers, request their review:

Via GitHub web interface:
1. Open your pull request
2. Click on "Reviewers" in the right sidebar
3. If code owners aren't already added, add them manually
4. Click "Request" next to their name

Via GitHub CLI:

bash
# Request review from a specific user
gh pr edit --add-reviewer @username

# Request review from a team
gh pr edit --add-reviewer @org/team-name

# View current PR status
gh pr status

Via email or chat:
If the review is urgent, contact the code owners directly through your team's communication channels. Include:
- Link to the pull request
- Summary of changes
- Why the changes are needed
- Any urgency or deadline

4Address review feedback and get approval

If a code owner has requested changes, you need to address their feedback:

View requested changes:
1. Go to the pull request "Files changed" tab
2. Look for comments with "Changes requested"
3. Address each concern with new commits

Update your branch:

bash
# Make the requested changes locally
git add .
git commit -m "Address code review feedback"
git push origin feature/my-changes

Request re-review:
After pushing your updates, the code owner needs to re-review. You can request a re-review:
1. Go to the PR's "Reviewers" section
2. Click the refresh icon next to the reviewer who requested changes
3. This notifies them that you've addressed their feedback

Important: Approval from *any one* of the listed code owners for a given path is typically sufficient, not all of them. Check your repository's branch protection settings for specific requirements.

5Handle unavailable code owners

If the designated code owner is unavailable (vacation, left the company, etc.), you have several options:

Option 1: Dismiss the stale review (requires admin access)
Repository admins can dismiss reviews:
1. Go to the pull request
2. Click on the review that's blocking
3. Click "Dismiss review"
4. Provide a reason for dismissal

Option 2: Contact a repository admin
Ask a repository administrator to:
- Dismiss the pending review
- Temporarily modify branch protection rules
- Add an alternative reviewer

Option 3: Update the CODEOWNERS file
If the code owner has permanently left, update the CODEOWNERS file:

bash
# Edit the CODEOWNERS file
vim .github/CODEOWNERS

# Replace @old-user with @new-user
# Then create a PR for this change (may need admin approval)

Option 4: Use bypass permissions
Some users may have "Allow specified actors to bypass required pull requests" permission in branch protection settings. Check with your repository admin.

6Check and configure branch protection rules

If you have admin access, you can review and modify branch protection settings:

View branch protection rules:
1. Go to repository Settings
2. Click "Branches" in the left sidebar
3. Find your protected branch and click "Edit"

Relevant settings:
- Require a pull request before merging: Prevents direct pushes
- Require review from Code Owners: The setting causing this error
- Required number of approvals: How many approvals needed
- Dismiss stale pull request approvals when new commits are pushed: Whether new commits require re-review
- Allow specified actors to bypass required pull requests: Users/teams who can bypass

To add bypass permissions:
1. In branch protection rules, find "Allow specified actors to bypass required pull requests"
2. Add specific users, teams, or apps that should have bypass ability
3. Use sparingly and only for trusted automation or leads

Note: Changing these settings requires admin permissions and should align with your team's security policies.

7Handle code owner reviews in CI/CD pipelines

If this error occurs in CI/CD pipelines, you need to ensure the workflow respects code owner requirements:

For GitHub Actions:

yaml
# Don't try to push directly to protected branches
# Instead, create a PR
name: Create Pull Request
on:
  push:
    branches:
      - feature/*

jobs:
  create-pr:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v5
        with:
          branch: automated-changes
          title: "Automated: Update from CI"
          reviewers: "@org/code-owners-team"

For automation that needs to bypass:
1. Create a GitHub App or machine user with bypass permissions
2. Add that actor to "Allow specified actors to bypass required pull requests"
3. Use a Personal Access Token (PAT) with appropriate scopes

bash
# Use a PAT with repo scope for the bypass user
git remote set-url origin https://x-access-token:${BYPASS_TOKEN}@github.com/org/repo.git
git push origin main

Warning: Bypassing code owner requirements in automation should be carefully considered. It's usually better to have automation create PRs that still require human approval.

Advanced notes

Understanding GitHub's Code Owner System:

The CODEOWNERS file uses gitignore-style patterns to match files and assign owners. Key rules:

1. Pattern matching: Uses the same rules as .gitignore (with some exceptions)
2. Last match wins: If multiple patterns match a file, the last pattern's owners are used
3. File location priority: GitHub checks .github/CODEOWNERS, then CODEOWNERS, then docs/CODEOWNERS
4. File size limit: CODEOWNERS files are limited to 3 MB

CODEOWNERS Syntax Examples:

bash
# Comment line
* @global-owner              # Default owner for all files

# Directory patterns
/docs/ @docs-team            # /docs directory only
docs/ @docs-team             # docs directory anywhere in repo
/src/api/** @api-team        # Recursive match

# File patterns
*.js @js-team                # All .js files
/src/*.ts @typescript-lead   # .ts files in /src only

# Multiple owners (any one can approve)
/security/ @security-team @cto

# Team syntax
/frontend/ @org/frontend-team

Branch Protection and Rulesets:

GitHub offers two systems for branch protection:

1. Classic Branch Protection: Settings per branch
2. Repository Rulesets (newer): More flexible, can target multiple branches with patterns

As of 2025, GitHub recommends using Rulesets for new configurations, though both work with CODEOWNERS.

Code Owner Approval Behavior:

- Only one code owner from a pattern needs to approve, not all
- If a PR touches files matching multiple patterns, an owner from each pattern must approve
- Code owners must have at least write access to the repository
- Draft PRs don't automatically request code owner reviews

Common Misconceptions:

1. "All listed owners must approve": False. Any one owner per file pattern is sufficient
2. "Code owners can be anyone": False. They must have write access
3. "CODEOWNERS applies to all branches": Each branch can have its own CODEOWNERS file

Troubleshooting CODEOWNERS:

bash
# Validate CODEOWNERS syntax on GitHub
# Go to: Settings > Branches > Branch protection rules
# Look for "CODEOWNERS file" validation warnings

# Test which owners match a file
# Use GitHub's "About code owners" page on any file:
# Click a file > three dots menu > "View code owners"

Security Considerations:

- Always protect the CODEOWNERS file itself: /.github/CODEOWNERS @security-team
- Regularly audit who has bypass permissions
- Use team reviews rather than individuals for bus-factor resilience
- Consider requiring multiple approvals for sensitive directories

Enterprise Features:

GitHub Enterprise offers additional capabilities:
- Required status checks integration with code owners
- Audit logs for code owner review bypasses
- SAML/SSO integration for code owner teams

Frequently asked questions

What does "GH006" mean?
The "GH006: Code owners review required" error indicates that GitHub's branch protection rules are blocking your push or merge operation. This happens when the target branch has the "Require review from Code Owners" protection rule enabled, and your changes affect files that have designated code owners who haven't approved the changes yet. Code owners are defined in a CODEOWNERS file within the repository, which specifies which users or teams are responsible for reviewing changes to specific files or directories.
How do I fix "GH006"?
This error occurs when you try to push or merge changes to a protected branch that requires approval from designated code owners. The branch protection rules enforce that any pull request modifying code owned by specific individuals or teams must be approved by those code owners before merging.
What causes "GH006"?
Branch protection requires code owner approval and you haven't received it yet You're trying to push directly to a protected branch instead of using a pull request The CODEOWNERS file designates specific reviewers for the files you modified
Is the "GH006" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading