无法签出远程git分支 [英] cannot checkout remote git branch

查看:137
本文介绍了无法签出远程git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在github本地克隆中。以下是分支机构的列表:

  $ git branch -a 
* master
online-demo
遥控器/原点/ HEAD->原始/主
远程/源/开发
远程/源/ gh页面
远程/源/主
远程/源/在线演示
远程/ pateketrueke / develop
遥控器/ pateketrueke / gh-pages
遥控器/ pateketrueke / master

当我尝试签出远程分支时,出现错误:

  $ git checkout开发
错误:pathspec 'develop'与git已知的任何文件都不匹配。

我不知道这是哪里来的。我想我已经进行了这么多年的结帐了。也许我想念一些东西。无论如何,我做了 git fetch git fetch origin git pull 因为我的想法用尽了,仍然存在相同的错误。

解决方案

您没有任何本地分支称为 develop 。当执行 git checkout开发且未找到本地分支时,git会理解您想创建一个名为 develop ,基于远程存储库中的 develop 分支(如果存在)。在您的情况下,您有2个这样的分支 origin / develop pateketrueke / develop ,所以存在歧义。 / p>

您可以使用以下格式对其进行更明确的显示:

  git分支开发原点/开发
git结帐开发

  git分支开发pateketrueke / develop 
git checkout开发

取决于您想要的内容。






这些可以缩写为:

  git checkout -b开发来源/开发

  git checkout -b开发pateketrueke / develop 


I'm in a github local clone. Below is the list of branches:

$ git branch -a
* master
  online-demo
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/gh-pages
  remotes/origin/master
  remotes/origin/online-demo
  remotes/pateketrueke/develop
  remotes/pateketrueke/gh-pages
  remotes/pateketrueke/master

When I try to checkout a remote branch, I get an error:

$ git checkout develop
error: pathspec 'develop' did not match any file(s) known to git.

I can't figure out where does that come from. I guess I've been doing such checkouts for ages. Maybe I'm missing something. Anyway, I did git fetch, git fetch origin and git pull because I'm running out of ideas and there's still the same error.

解决方案

You don't have any local branch called develop. When doing git checkout develop and no local branches are found, git will understand that you want to make a new local branch called develop, based on a develop branch in a remote repo, if any exists. In your case, you have 2 such branches origin/develop and pateketrueke/develop, so there is an ambiguity.

You can be more explicit about it by using the following form:

git branch develop origin/develop
git checkout develop

or

git branch develop pateketrueke/develop
git checkout develop

depending on what you want.


These can be abbreviated as:

git checkout -b develop origin/develop

or

git checkout -b develop pateketrueke/develop

这篇关于无法签出远程git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆