我在本地Git仓库中设置了两个遥控器。一个是我正在为其做出贡献的开源项目的仓库,另一个是该仓库的我的分支。
似乎我只能检出从origin
远程下载的内容。我通常从远程获取分支的方法如下:
$ git fetch <remote> <branch>
$ git checkout <branch>
但是在我的当前情况下,这似乎行不通。
$ git fetch my-remote my-branch
remote: Counting objects: 2297, done.
remote: Compressing objects: 100% (1951/1951), done.
remote: Total 2297 (delta 1044), reused 0 (delta 0), pack-reused 50
Receiving objects: 100% (2297/2297), 2.10 MiB | 1.59 MiB/s, done.
Resolving deltas: 100% (1045/1045), done.
From https://github.com/me/my-repo
* branch my-branch -> FETCH_HEAD
* [new branch] my-branch -> origin/my-branch
$ git checkout my-branch
error: pathspec 'my-branch' did not match any file(s) known to git.
而且,当我执行git branch
时,该分支并不存在。
这是怎么回事?
git branch --all
命令告诉你什么? - ckruczekcheckout.defaultRemote=origin
。请参见下面的答案。 - VonC