【问题标题】:How to solve "git checkout branch" did not match any file(s) known to git?如何解决“git checkout branch”与git已知的任何文件不匹配?
【发布时间】:2021-09-12 12:53:24
【问题描述】:

bitbucket 上有一个存储库,我有一个分支。

当我写:git branch -a 时,我只得到我当前的分支,它没有列出其他分支。

当我写git checkout branch_name 时,我得到:error: pathspec 'branch_name' did not match any file(s) known to git

git remote show origin:

* remote origin
  Fetch URL: ssh:URL
  Push  URL: ssh:URL
  HEAD branch: master
  Remote branch:
    branch_name tracked
  Local branch configured for 'git pull':
    branch_name merges with remote branch_name
  Local ref configured for 'git push':
    branch_name pushes to branch_name (up to date)

git branch --all -vv

* branch_name                {an id} [origin/branch_name] A commit
  remotes/origin/branch_name {an id} A commit

【问题讨论】:

  • git remote -vv 显示什么?它是否显示您的 bitbucket 存储库的 URL?您是从该存储库克隆还是在本地初始化了一个空存储库?
  • 是的,它显示了 URL。我克隆了它。
  • 请在您的问题中提供git branch --all -vvgit remote show origin的实际输出
  • 尝试git fetch 然后git checkout

标签: git


【解决方案1】:

问题是当你克隆这个 repo 时,你做了一个单分支克隆。所以你请求的分支是你能看到的唯一分支。

(对于“解决方案”,请参阅How do I "undo" a --single-branch clone?。)

【讨论】:

    猜你喜欢
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    • 2013-06-01
    • 1970-01-01
    • 2020-06-17
    • 1970-01-01
    • 1970-01-01
    • 2015-02-04
    相关资源
    最近更新 更多