跳转至

Git clone 指定的分支


2017-10-31 by dongnan

举个栗子

克隆某个项目的 online 分支。

git clone -b online git@git.zongming.net:git/irm-py.git
正克隆到 'online'...
remote: Counting objects: 83, done.
remote: Compressing objects: 100% (78/78), done.
remote: Total 83 (delta 35), reused 0 (delta 0)
接收对象中: 100% (83/83), 41.17 KiB | 0 bytes/s, done.
处理 delta 中: 100% (35/35), done.
检查连接... 完成。

步骤

当前分支

git branch
* online

全部分支

git branch -a
* online
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/online

参数

man git-clone
       --branch <name>, -b <name>
           Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, 
            point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. 
            --branch can also take tags and detaches the HEAD at that commit in the resulting repository.



回到页面顶部