git get a copy of a branch

how do I get a copy of a branch from a remote git server? I have tried the following options

git clone url
git clone url branchName  

it looks they get the master copy.


You can use the the --branch or -b option on clone:

git clone -b <name> url

See man git clone for further details.


when you clone you get ALL the branches and history.

good explanation here: git branch, fork, fetch, merge, rebase and clone, what are the differences?

use:

git-branch

once you clone the repository to see the branches in the repository.


git clone url
git branch branchname
git checkout branchname
git pull origin branchname

this works for me afa i remember. there might be some better way though, i'm not a git pro.

链接地址: http://www.djcxy.com/p/7554.html

上一篇: 如何使用git? 混帐

下一篇: git获得一个分支的副本