git auth_error ai_generated partial

远程:错误:无法推送到受保护的引用 'refs/heads/main'

remote: error: cannot push to a protected ref 'refs/heads/main'

ID: git/push-delete-refspec

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

版本兼容性

版本状态引入弃用备注
git 2.37.0 active
git 2.41.0 active
git 2.44.0 active

根因分析

尝试推送到受仓库规则保护的(例如 GitHub 分支保护)分支,需要拉取请求或管理员批准。

English

Attempt to push to a branch that is protected by repository rules (e.g., GitHub branch protection), requiring pull requests or admin approval.

generic

官方文档

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

解决方案

  1. Create a new branch, push it, and open a pull request for review: 'git checkout -b feature-branch && git push origin feature-branch'.
  2. Request admin to temporarily disable branch protection, then push.

无效尝试

常见但无效的做法:

  1. 95% 失败

    Forcing push with 'git push --force' will be rejected by the remote server.

  2. 90% 失败

    Deleting the protected branch locally and pushing again will fail due to remote protection.