【问题标题】:Missing branch from 'git branch -a' but shows up with 'git ls-remote origin''git branch -a' 缺少分支,但显示为 'git ls-remote origin'
【发布时间】:2020-04-12 10:06:27
【问题描述】:

我通过 Azure DevOps 门户创建了一个分支,我想签出该分支。但是,当我运行

git checkout remotes/origin/dev/<branch name>

它返回“错误:pathspec 'remotes/origin/dev/branchname' 与 git 已知的任何文件不匹配”

所以我跑了

git branch -a

并且分支不在输出中。

然后我跑

git ls-remote origin

并且分支在那里并且具有与以 'git branch -a' 显示的分支相同的 refs/heads/ 前缀!有没有其他方法可以获取从“git ls-remote origin”显示的分支?

【问题讨论】:

  • 你试过了吗:git checkout <branch name>?让 Git 操心吧;)
  • 试过git fetch ?

标签: git azure-devops git-branch git-checkout


【解决方案1】:

您需要先fetch 远程的更改,以确保远程的头、提交和标签在您的本地存储库中可用。之后你可以使用checkout切换到分支。

【讨论】:

    猜你喜欢
    • 2015-01-20
    • 2018-10-18
    • 2015-10-03
    • 1970-01-01
    • 1970-01-01
    • 2015-11-15
    • 2012-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多