有人推了一个分行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)
当前回答
要克隆 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
要切换到另一个分支
git checkout BranchName
如果远程分支名称是以特殊字符开头的,您需要在退出命令中使用单引号,否则Git将不知道您在谈论哪个分支。
例如,我试图查看一个远程分支 命名为#9773
,但如下图所示,命令没有正常工作:
出于某种原因,我想知道尖锐符号(###)是否与它有关,然后我试图用单引号绕绕分支名称,例如'#9773'
而不是仅仅#9773
幸运的是,它的工作很好。
git checkout -b '#9773' origin/'#9773'
我被困在一个状况中看到error: pathspec 'desired-branch' did not match any file(s) known to git.
以上所有建议。我正在讨论Git 1.8.3.1版本。
所以这个为我工作:
git fetch origin desired-branch
git checkout -b desired-branch FETCH_HEAD
背后的解释是,我注意到 当我拿起遥控树枝时,时前:
git fetch origin desired-branch
From github.com:MYTEAM/my-repo
* branch desired-branch -> FETCH_HEAD
工作命令
git fetch origin 'remote_branch':'local_branch_name'
git switch 'local_branch_name'
git pull origin 'remote_branch':'local_branch_name'
第一个是从远程分支获取分支和创建本地分支。
第二个是转换到当地分行。
第三是将最近的远距离变化推到当地分部。
在这种情况下,你可能想要 创建本地test
正在跟踪远程test
分支 :
$ git branch test origin/test
先前版本的git
,你需要一个明确的--track
选项,但当您正在从一个远程分支进行分支分割时,这是默认值。
创建本地分支和切换到它,使用:
$ git checkout -b test origin/test