无法从GitHub分叉存储库签出分支

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法从GitHub分叉存储库签出分支相关的知识,希望对你有一定的参考价值。

我试图从我的分叉存储库中检出一个分支,但它给出了一个错误:

存储库:https://github.com/tmsblgh/codechecker/tree/issue799

MacBook-Pro:codechecker tmsblgh$ git branch -vv
* master acdc482 [origin/master] Merge pull request #1636 from gyorb/version68
MacBook-Pro:codechecker tmsblgh$ git --version
git version 2.17.1
MacBook-Pro:codechecker tmsblgh$ git fetch
MacBook-Pro:codechecker tmsblgh$ git checkout issue799
error: pathspec 'issue799' did not match any file(s) known to git.
Baloghs-MacBook-Pro:codechecker tmsblgh$ git remote -v
origin  https://github.com/tmsblgh/codechecker.git (fetch)
origin  https://github.com/tmsblgh/codechecker.git (push)
MacBook-Pro:codechecker tmsblgh$ git checkout issue799
error: pathspec 'issue799' did not match any file(s) known to git.
答案

看来当地的回购没有origin/issue799

#fetch the branch
git fetch origin issue799

#see if origin/issue799 exists
git branch -a

#if yes
git checkout issue799

#if not, create the local branch from FETCH_HEAD
git checkout -b issue799 FETCH_HEAD

#the next push after you make some new commits
git push -u origin issue799
另一答案

这个分支可能不在您的本地git设置中。试试git checkout origin/issue799

P.S。:起源是您指向的遥控器

另一答案

您可以设置本地分支来跟踪远程:

git checkout -b issue799 origin/issue799

编辑(回应评论):

我不知道你为什么会收到错误,但这是我从头开始做的事情,它似乎对我有用:

 $ git clone https://github.com/tmsblgh/codechecker.git
 Cloning into 'codechecker'...
 remote: Counting objects: 14825, done.        
 remote: Total 14825 (delta 0), reused 0 (delta 0), pack-reused 14825        
 Receiving objects: 100% (14825/14825), 12.57 MiB | 22.70 MiB/s, done.
 Resolving deltas: 100% (10329/10329), done.

 $ cd codechecker/
 /home/nick/tmp/codechecker

 $ git branch
 * master

 $ git remote -v
 origin https://github.com/tmsblgh/codechecker.git (fetch)
 origin https://github.com/tmsblgh/codechecker.git (push)

 $ git checkout -b issue799 origin/issue799 
 Branch issue799 set up to track remote branch iue799 from origin.
 Switched to a new branch 'issue799'

以上是关于无法从GitHub分叉存储库签出分支的主要内容,如果未能解决你的问题,请参考以下文章

将多个 git 存储库签出到同一个 Jenkins 工作区

git:如何从远程分支获取并合并到本地分支?

是否可以在 Github 中“分叉”?

无法使用 npm 从分叉的 github 存储库安装

vscode 用git 拉取代码,提示:在签出前,请清理存储库工作树。请问是啥问题,如何解决。

无法通过 file:// 签出本地 svn 存储库