我克隆了一个远程分支。我如何结账大师?

I cloned a remote branch. How do I checkout master?

我克隆了一个远程分支 git clone --single-branch --branch <branchname> <remote-repo> 。 现在我想结帐大师。当我尝试 git checkout master 时,我收到此错误消息:error: pathspec 'master' did not match any file(s) known to git。 如何在不必单独克隆的情况下检出 master?

来自doc :

"Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning."

恐怕你必须在没有选项的情况下重新克隆。

请注意 remote-tracking 分支不是 local 分支。重新克隆不会为每个远程分支创建本地分支,即使 without --single-branch