【发布时间】:2018-09-13 02:34:15
【问题描述】:
我正在做一个有两个遥控器的项目,一个叫origin,一个叫vsts。默认遥控器是origin。这是git remote -v 的输出,其中一些部分匿名为***:
$ git remote -v
origin git@bitbucket.org:***/***.git (fetch)
origin git@bitbucket.org:***/***.git (push)
vsts ssh://***@vs-ssh.visualstudio.com:***/DefaultCollection/***/_ssh/*** (fetch)
vsts ssh://***@vs-ssh.visualstudio.com:***/DefaultCollection/***/_ssh/*** (push)
我正在尝试从vsts 签出一个新分支。它被称为release/1.4.1。我在 Git 2.16.x 上,所以我应该可以使用 git checkout,但会发生这种情况:
$ git checkout release/1.4.1
error: pathspec 'release/1.4.1' did not match any file(s) known to git.
我想可能是假设我的意思是origin。所以我试试这个:
$ git checkout vsts/release/1.4.1
error: pathspec 'vsts/release/1.4.1' did not match any file(s) known to git.
我应该确保 git 可以找到分支。所以我使用git ls-remote 来获取远程分支的列表:
$ git ls-remote vsts
...
abcde*** refs/heads/release/1.4.1
...
我得到一个分支列表和提交哈希,release/1.4.1 绝对是其中之一。
我尝试了更多的东西:
$ git checkout -b release/1.4.1 vsts/release/1.4.1
fatal: 'vsts/release/1.4.1' is not a commit and a branch 'release/1.4.1' cannot be created from it
$ git fetch vsts release/1.4.1
From ssh://vs-ssh.visualstudio.com:***/DefaultCollection/***/_ssh/***
* branch release/1.4.1 -> FETCH_HEAD
(这个命令之后,我把前面的都试了一遍,结果还是没变。)
$ git checkout -b release/1.4.1 remotes/vsts/release/1.4.1
fatal: 'remotes/vsts/release/1.4.1' is not a commit and a branch 'release/1.4.1' cannot be created from it
$ git checkout -b release/1.4.1 remotes/vsts/refs/heads/release/1.4.1
fatal: 'remotes/vsts/refs/heads/release/1.4.1' is not a commit and a branch 'release/1.4.1' cannot be created from it
如果我尝试git pull vsts/release/1.4.1,它会成功地将远程分支release/1.4.1 合并到当前分支中,但这不是一个有用的解决方法。
我还能尝试什么?我不明白为什么我不能签出远程分支。
【问题讨论】:
标签: git git-checkout git-remote