xxxxxxxxxx
# 1. Switch to the repository's directory
cd /path/to/repository
# 2. Create a new branch
git branch new-branch-name original-branch-name
# 3. Push the new branch to the remote repository if desired
git push origin new-branch-name
xxxxxxxxxx
In general:
git clone -b <branch> <remote_repo>
Example:
git clone -b develop git@github.com:user/myproject.git
xxxxxxxxxx
# syntax
git clone -b <branch> <remote_repo>
# Example
git clone -b my-branch git@github.com:user/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 opencv-2.4 --single-branch https://github.com/Itseez/opencv.git
xxxxxxxxxx
git clone -b <branch> <remote_repo>
git clone -b my-branch git@github.com:user/myproject.git
xxxxxxxxxx
git clone --single-branch --branch <branchname> <remote-repo>
# eg
git clone -b opencv-2.4 --single-branch https://github.com/Itseez/opencv.git
xxxxxxxxxx
clone specefic branch in git
git clone --single-branch --branch <branchname> <remote-repo>