# 远程：错误：GH006：不允许推送到受保护分支 'main'。

- **ID:** `git/remote-rejected-branch-protection`
- **领域:** git
- **类别:** auth_error
- **错误码:** `GH006`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

远程仓库（例如 GitHub）具有分支保护规则，阻止直接推送到某些分支（如 'main'）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| git 2.30.0 | active | — | — |
| git 2.37.0 | active | — | — |
| git 2.43.0 | active | — | — |

## 解决方案

1. ```
   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.
   ```
3. ```
   Use 'git push origin main:refs/heads/main' but only if you have bypass permissions; otherwise, use pull requests.
   ```

## 无效尝试

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