git clone specific branch only

C++
git clone -b <branchName> <remote_repo_url>In general:

git clone -b <branch> <remote_repo>

Example:

git clone -b develop [email protected]:user/myproject.gitgit clone -b mybranch --single-branch git://sub.domain.com/repo.gitgit clone --single-branch --branch <branchname> <remote-repo>

# eg
git clone -b opencv-2.4 --single-branch https://github.com/Itseez/opencv.gitgit clone -b <branch> <remote_repo>git clone --single-branch --branch <branchname> <remote-repo>

Source

Also in C++: