Skip to content

Stale Remote-Tracking 分支

错误信息

                你的分支是后面 '原点/主要' 通过 N 提交, and 能是快-forwarded.
              

快速摘要

你的局部分支有不是更新使用 latest remote 提交 — 你是后面 and 应该拉取.

为什么发生

  • 你有不 pulled 由于 others pushed 到 remote

  • 你的 remote-tracking refs 是 stale (有不获取)

  • 你是工作 on outdated 局部复制

最小示例

✗ 错误代码
git status  # Your branch is behind 'origin/main' by 5 commits
✓ 修复代码
git pull origin main  # or git pull --rebase origin main
git status  # Your branch is up to date with 'origin/main'

拉取到 integrate remote 提交你是 missing. 你的局部分支将是更新到 match remote.

如何诊断

  • 运行 git 状态到 see 如何许多提交后面你是

  • 运行 git 获取到更新 remote-tracking refs

  • 运行 git log HEAD..原点/主要到 see 什么你是 missing

如何修复

  • 拉取到更新: git 拉取 (or git 拉取 --rebase for cleaner history)

  • 如果你有局部提交, 拉取将合并 or rebase 它们使用 remote 更改

  • 如果你有否局部提交, 拉取将快-向前

如何预防

  • 拉取 at 开始的每个工作会话到 stay in sync

  • 拉取之前 pushing 到 avoid 拒绝 pushes

相关资源

相关术语

相关课程

← 返回语言