How to clone a specific git branch?

git clone -b <branch> <remote_repo>

Example:

git clone -b my-branch git@github.com:user/myproject.git

Alternative (no public key setup needed):

git clone -b my-branch https://git@github.com/username/myproject.git

With Git 1.7.10 and later, add --single-branch to prevent fetching of all branches. Example, with OpenCV 2.4 branch:

git clone -b 2.4 --single-branch https://github.com/Itseez/opencv.git opencv-2.4

 


https://stackoverflow.com/a/4568323/4862158

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s