# remote: error: GH006: Push to protected branch 'main' is not allowed.

- **ID:** `git/remote-rejected-branch-protection`
- **Domain:** git
- **Category:** auth_error
- **Error Code:** `GH006`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The remote repository (e.g., GitHub) has branch protection rules that prevent direct pushes to certain branches like 'main'.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| git 2.30.0 | active | — | — |
| git 2.37.0 | active | — | — |
| git 2.43.0 | active | — | — |

## Workarounds

1. **Create a new branch and push there: git checkout -b feature-branch && git push origin feature-branch, then open a pull request.** (95% success)
   ```
   Create a new branch and push there: git checkout -b feature-branch && git push origin feature-branch, then open a pull request.
   ```
2. **If you have admin rights, temporarily disable branch protection in the repository settings, push, then re-enable.** (80% success)
   ```
   If you have admin rights, temporarily disable branch protection in the repository settings, push, then re-enable.
   ```
3. **Use 'git push origin main:refs/heads/main' but only if you have bypass permissions; otherwise, use pull requests.** (70% success)
   ```
   Use 'git push origin main:refs/heads/main' but only if you have bypass permissions; otherwise, use pull requests.
   ```

## Dead Ends

- **** — Branch protection rules on the server still reject force pushes; may also cause security alerts. (90% fail)
- **** — Authentication is not the issue; the server enforces the rule regardless of credentials. (100% fail)
- **** — Does not affect the remote branch protection; push still fails. (95% fail)
