git
protocol_error
ai_generated
true
! [拒绝] main -> main(非快进)
! [rejected] main -> main (non-fast-forward)
ID: git/push-rejected-non-fast-forward
90%修复率
85%置信度
1证据数
2023-02-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| git 2.20 | active | — | — | — |
| git 2.30 | active | — | — | — |
| git 2.45 | active | — | — | — |
根因分析
本地分支落后于远程分支,无法快进;Git 拒绝在没有强制推送的情况下覆盖远程提交。
English
Local branch is behind the remote branch and cannot be fast-forwarded; Git refuses to overwrite remote commits without force push.
官方文档
https://git-scm.com/docs/git-push#Documentation/git-push.txt---force解决方案
-
Pull the latest remote changes and merge or rebase: git pull origin main --rebase
-
If you are sure you want to overwrite remote history, use force push with lease: git push --force-with-lease origin main
无效尝试
常见但无效的做法:
-
60% 失败
Force push can overwrite remote commits, potentially losing work from other contributors; it should be used with caution.
-
95% 失败
The error is about commit history divergence, not connectivity; retrying won't change the history mismatch.