git
runtime_error
ai_generated
true
提示:(例如,'git pull ...')然后再推送。
hint: (e.g., 'git pull ...') before pushing again.
ID: git/diverged-branches-fast-forward-rejected
90%修复率
85%置信度
1证据数
2023-11-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| git 2.30 | active | — | — | — |
| git 2.35 | active | — | — | — |
| git 2.40 | active | — | — | — |
根因分析
本地分支与远程分支已分叉,因此快速推送被拒绝;用户需要先整合远程更改。
English
Local branch has diverged from remote branch, so fast-forward push is rejected; user needs to integrate remote changes first.
官方文档
https://git-scm.com/docs/git-push#_notes解决方案
-
Run 'git pull origin main --ff-only' to fast-forward if possible, then retry push
-
Run 'git pull origin main --rebase' to rebase local commits on top of remote, then push
-
If divergence is intentional, use 'git push --force-with-lease' to safely override remote
无效尝试
常见但无效的做法:
-
Run git pull --rebase without checking for conflicts
50% 失败
If conflicts exist, rebase will abort or create messy history; also may lose merge commits.
-
Use git push --force to override remote
80% 失败
Dangerous on shared branches; may delete others' commits and cause data loss.
-
Ignore the hint and retry push without pulling
100% 失败
Same error will occur because local is still behind remote.