有人推了一个分行test
与git push origin test
共享仓库的共享仓库。git branch -r
如何查看遥控器test
我试过了
git checkout test
,它没有做任何事情git checkout origin/test
给给* (no branch)
有人推了一个分行test
与git push origin test
共享仓库的共享仓库。git branch -r
如何查看遥控器test
我试过了
git checkout test
,它没有做任何事情git checkout origin/test
给给* (no branch)
当前回答
在这种情况下,你可能想要 创建本地test
正在跟踪远程test
分支 :
$ git branch test origin/test
先前版本的git
,你需要一个明确的--track
选项,但当您正在从一个远程分支进行分支分割时,这是默认值。
创建本地分支和切换到它,使用:
$ git checkout -b test origin/test
其他回答
我尝试了上面的解决方案,但行不通。试试这个,它奏效了:
git fetch origin 'remote_branch':'local_branch_name'
这将获取远程分支, 并创建一个新本地分支( 如果尚未存在) 名称local_branch_name
并追踪其中的遥控者。
虽然第一个和选定的答案是技术上的正确中,您可能尚未从远程仓库中检索到所有对象和参考文献。如果是这种情况,您将会收到以下错误:
$ git checkout -b remote_branch origin/remote_branch
致命: git 检出: 更新路径与切换分支不兼容 。
您是否打算检查“ 来源/ remote_ branch ” 无法以承诺方式解决的“ 来源/ 远程- branch ” ?
如果您收到此消息, 您必须首先完成git fetch origin
何 地origin
是运行前的远程仓库的名称git checkout remote_branch
。以下是答复的完整例子:
$ git fetch origin
remote: Counting objects: 140, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 69 (delta 36), reused 66 (delta 33)
Unpacking objects: 100% (69/69), done.
From https://github.com/githubuser/repo-name
e6ef1e0..5029161 develop -> origin/develop
* [new branch] demo -> origin/demo
d80f8d7..359eab0 master -> origin/master
$ git checkout demo
Branch demo set up to track remote branch demo from origin.
Switched to a new branch 'demo'
如你所见 跑着跑着git fetch origin
检索到我们尚未安装的远程分支, 以跟踪本地机器 。 从那里, 因为我们现在有一个 ref 到远程分支, 我们就可以运行git checkout remote_branch
我们会从远程追踪中受益
在我看来,没有人建议 最简单的方法(也许我太笨了 觉得这太蠢了)"一种方式"但无论如何,试试这个:
git pull origin remoteBranchName
git switch remoteBranchName
这对我也有效(在我最后一次拉拉请求后,在遥控器上创建了一个分支)。
要克隆 Git 仓库, 需要 :
git clone <either ssh url /http url>
上述命令检查了所有分支,但只检查了master
将初始化分支。 如果您想要检查其它分支, 请做 :
git checkout -t origin/future_branch (for example)
此命令检查远程分支, 您的本地分支名称将与远程分支相同 。
如果您想要在检查退出时覆盖您的本地分支名称 :
git checkout -t -b enhancement origin/future_branch
现在您的本地分支名称是enhancement
,但您的远程分支名称是future_branch
.
你可以试试
git fetch remote
git checkout --track -b local_branch_name origin/branch_name
或
git fetch
git checkout -b local_branch_name origin/branch_name