有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :

git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)


当前回答

i 被困在一个看到错误的情况中: 路径谱“ 想要的分支” 与上述所有建议已知的 Git 匹配的文件不匹配 。 i' 正在 Git 1. 8. 3. 3.1 版本上 。

因此,这对我有效:

git fetch origin desired-branch
git checkout -b desired-branch FETCH_HEAD

背后的解释是,我已经注意到, 当拿起远程分支时, 它被拿到fick_head:

git fetch origin desired-branch

From github.com:MYTEAM/my-repo
    * branch            desired-branch -> FETCH_HEAD

其他回答

git 获取\ \ \ git 检查您的处名

在此情况下, 您可能想要创建一个本地测试分支, 跟踪远程测试分支 :

$ git branch test origin/test

在早期版本的 git 中, 您需要一个明确的 -- track 选项, 但是当您正在将远程分支分割出来时, 这是默认的 。

创建本地分支并切换到它,使用:

$ git checkout -b test origin/test

git 远程显示 & lt; 原始名称 & gt; 命令将列出所有分支( 包括未跟踪的分支) 。 然后您可以找到要获取的远程分支名称 。

例如:

git remote show origin

使用这些步骤获取远程分支 :

git fetch <origin name> <remote branch name>:<local branch name>
git checkout <local branch name > (local branch name should the name that you given fetching)

例如:

git fetch origin test:test
git checkout test

因为某种原因,我不能做:

git checkout -b branch-name origin/branch-name

它扔出错误:

致命 : “ 来源/ 分支名称” 不是一个承诺, 无法从中创建分支“ 分支名称 ” 。

我不得不这样做:

git checkout -b branch-name commit-sha

用途 :

git checkout -b <BRANCH-NAME> <REMOTE-NAME>/<BRANCH-NAME>

其它的答案对我的良性案例中的现代 Git 无效。 如果远程分支是新的, 您可能需要先拉一下, 但我还没有检查过这个案例 。