GH006 git auth_error ai_generated true

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

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

ID: git/remote-rejected-branch-protection

其他格式: JSON · Markdown 中文 · English
85%修复率
86%置信度
1证据数
2023-02-14首次发现

版本兼容性

版本状态引入弃用备注
git 2.30.0 active — — —
git 2.37.0 active — — —
git 2.43.0 active — — —

根因分析

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

English

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

generic

官方文档

https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 90% 失败

    Branch protection rules on the server still reject force pushes; may also cause security alerts.

  2. 100% 失败

    Authentication is not the issue; the server enforces the rule regardless of credentials.

  3. 95% 失败

    Does not affect the remote branch protection; push still fails.