git
runtime_error
ai_generated
true
error: failed to push some refs to 'origin' hint: Updates were rejected because the remote contains work that you do not have locally.
ID: git/push-non-fast-forward
88%Fix Rate
87%Confidence
1Evidence
2023-04-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| git 2.31.0 | active | — | — | — |
| git 2.39.0 | active | — | — | — |
| git 2.44.0 | active | — | — | — |
Root Cause
Local branch is behind the remote branch; push is rejected to prevent overwriting remote changes.
generic中文
本地分支落后于远程分支;拒绝推送以防止覆盖远程更改。
Official Documentation
https://git-scm.com/docs/git-pushWorkarounds
-
90% success Pull the remote changes first: 'git pull origin main --rebase' to rebase local commits on top, then push again.
Pull the remote changes first: 'git pull origin main --rebase' to rebase local commits on top, then push again.
-
85% success If conflicts occur, resolve them manually, then continue the rebase with 'git rebase --continue' and push.
If conflicts occur, resolve them manually, then continue the rebase with 'git rebase --continue' and push.
中文步骤
Pull the remote changes first: 'git pull origin main --rebase' to rebase local commits on top, then push again.
If conflicts occur, resolve them manually, then continue the rebase with 'git rebase --continue' and push.
Dead Ends
Common approaches that don't work:
-
70% fail
Using 'git push --force' may overwrite remote commits and cause data loss for collaborators.
-
50% fail
Running 'git pull' without merging may result in merge conflicts if not handled properly.