Skip to content

能不查找 Remote Ref

错误信息

                fatal: 能不查找 ref 那个 matches upstream/feature
              

快速摘要

你 referenced remote 分支那个做不 exist — 它可能不有是 pushed yet or 是删除.

为什么发生

  • 分支是从不 pushed 到 remote

  • 分支是删除 on remote

  • 你有不获取 recently and 你的 remote-tracking refs 是 stale

  • Typo in 分支 or remote name

最小示例

✗ 错误代码
git checkout origin/feature  # fatal: could not find a ref that matches origin/feature
✓ 修复代码
git fetch origin
git branch -r  # verify the branch exists
git checkout origin/feature  # now works if it exists

获取到更新 remote-tracking refs, 然后验证分支 exists 使用 git 分支 -r 之前检查 out.

如何诊断

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

  • 运行 git 分支 -r 到列表所有 remote-tracking 分支

  • 验证 remote and 分支 names 是正确

如何修复

  • 获取首先: git 获取原点, 然后 retry

  • 如果分支做不 exist on remote, 推送它: git 推送 -u 原点 <分支>

  • Fix typos in remote or 分支 name

  • 如果分支是删除, 创建它再次 or use 不同分支

如何预防

  • 运行 git 获取之前 referencing remote 分支

  • Use git 分支 -r 到验证 remote 分支 exist

相关资源

相关术语

相关课程

← 返回语言