git runtime_error ai_generated true

hint: (e.g., 'git pull ...') before pushing again.

ID: git/diverged-branches-fast-forward-rejected

Also available as: JSON · Markdown · 中文
90%Fix Rate
85%Confidence
1Evidence
2023-11-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
git 2.30 active
git 2.35 active
git 2.40 active

Root Cause

Local branch has diverged from remote branch, so fast-forward push is rejected; user needs to integrate remote changes first.

generic

中文

本地分支与远程分支已分叉,因此快速推送被拒绝;用户需要先整合远程更改。

Official Documentation

https://git-scm.com/docs/git-push#_notes

Workarounds

  1. 80% success Run 'git pull origin main --ff-only' to fast-forward if possible, then retry push
    Run 'git pull origin main --ff-only' to fast-forward if possible, then retry push
  2. 90% success Run 'git pull origin main --rebase' to rebase local commits on top of remote, then push
    Run 'git pull origin main --rebase' to rebase local commits on top of remote, then push
  3. 85% success If divergence is intentional, use 'git push --force-with-lease' to safely override remote
    If divergence is intentional, use 'git push --force-with-lease' to safely override remote

中文步骤

  1. Run 'git pull origin main --ff-only' to fast-forward if possible, then retry push
  2. Run 'git pull origin main --rebase' to rebase local commits on top of remote, then push
  3. If divergence is intentional, use 'git push --force-with-lease' to safely override remote

Dead Ends

Common approaches that don't work:

  1. Run git pull --rebase without checking for conflicts 50% fail

    If conflicts exist, rebase will abort or create messy history; also may lose merge commits.

  2. Use git push --force to override remote 80% fail

    Dangerous on shared branches; may delete others' commits and cause data loss.

  3. Ignore the hint and retry push without pulling 100% fail

    Same error will occur because local is still behind remote.