【发布时间】:2017-05-14 16:57:04
【问题描述】:
我想将此分支添加到我的本地克隆: https://github.com/dmitriz/mithril.js/tree/rewrite
由于某些不清楚的原因,它没有被克隆。
所以我最终得到了没有该分支的本地目录。是否也有任何简单的方法可以克隆此分支?
【问题讨论】:
标签: git github branch git-branch git-remote
我想将此分支添加到我的本地克隆: https://github.com/dmitriz/mithril.js/tree/rewrite
由于某些不清楚的原因,它没有被克隆。
所以我最终得到了没有该分支的本地目录。是否也有任何简单的方法可以克隆此分支?
【问题讨论】:
标签: git github branch git-branch git-remote
我假设您最初克隆的存储库是您的origin。
所以只需执行git fetch origin,它应该会在git branch -a 上弹出 - 之后您可以使用git checkout -b rewrite origin/rewrite 轻松查看它。
一个可能的解释是,当您最初克隆它时,该分支根本不存在,并且您从未获取所有(新)分支。
【讨论】:
fatal: Cannot update paths and switch to branch 'rewrite' at the same time. Did you intend to checkout 'origin/rewrite' which can not be resolved as commit?
你所要做的就是签出这个分支。
$ git checkout rewrite
Git 将切换到一个新分支,跟踪远程分支。这是您应该收到的消息
Branch rewrite set up to track remote branch rewrite from origin.
Switched to a new branch 'rewrite'
【讨论】:
$ git checkout rewrite --- error: pathspec 'rewrite' did not match any file(s) known to git.
如果您克隆存储库,则您已经拥有所有分支。您需要做的就是从中创建一个本地分支,因为它是一个分布式 scm。
git checkout -b rewrite origin/rewrite
您也可以为您的本地分支机构取其他名称,或者拥有多个副本。
【讨论】:
$ git checkout -b rewrite origin/rewritefatal: Cannot update paths and switch to branch 'rewrite' at the same time.Did you intend to checkout 'origin/rewrite' which can not be resolved as commit?