1 摘要

当我们从远程仓库克隆时,默认情况下只会克隆到远程仓库的master分支,如果远程仓库还有其他分支默认是不能clone的。

2 克隆其他分支

2.1 列出所有分支

$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/topeet

可以看到远程仓库包括master分支和topeet。目前已经存在master分支。

2.2 checkout远程分支

$ git checkout -b topeet origin/topeet 
Branch 'topeet' set up to track remote branch 'topeet' from 'origin'.
Switched to a new branch 'topeet'

这样就把远程的topeet分支checkout到了本地,并切换到topeet分支