git
protocol_error
ai_generated
true
! [rejected] main -> main (non-fast-forward)
ID: git/push-rejected-non-fast-forward
90%Fix Rate
85%Confidence
1Evidence
2023-02-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| git 2.20 | active | — | — | — |
| git 2.30 | active | — | — | — |
| git 2.45 | active | — | — | — |
Root Cause
Local branch is behind the remote branch and cannot be fast-forwarded; Git refuses to overwrite remote commits without force push.
generic中文
本地分支落后于远程分支,无法快进;Git 拒绝在没有强制推送的情况下覆盖远程提交。
Official Documentation
https://git-scm.com/docs/git-push#Documentation/git-push.txt---forceWorkarounds
-
90% success Pull the latest remote changes and merge or rebase: git pull origin main --rebase
Pull the latest remote changes and merge or rebase: git pull origin main --rebase
-
80% success If you are sure you want to overwrite remote history, use force push with lease: git push --force-with-lease origin main
If you are sure you want to overwrite remote history, use force push with lease: git push --force-with-lease origin main
中文步骤
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
Dead Ends
Common approaches that don't work:
-
60% fail
Force push can overwrite remote commits, potentially losing work from other contributors; it should be used with caution.
-
95% fail
The error is about commit history divergence, not connectivity; retrying won't change the history mismatch.