How to clone a specific Git branch ?
Here your following solution;
And the difference is: by invoking git clone –branch <branchname> url you’re fetching all the branches and checking out one for instance, mean that your repository has a 5kB documentation or wiki branch and 5GB data branch and you want to edit your frontpage, you may end up cloning 5GB of data.
git clone –branch is not the way to accomplish asking about cloning a specific branch.
git clone --single-branch --branch <branchname> host:/dir.git
–single-branch option, but let’s preserve it for full satisfaction
git init git remote add -t refspec remotename host:/dir.git git fetch
Here your simple code:
git clone -b <branch> <remote_repo>
git clone -b my-branch [email protected]:user/myproject.git
Git 1.7.10 and later, add –single-branch to prevent fetching of all branches e.g. OpenCV 2.4 branch:
git clone -b opencv-2.4 --single-branch https://github.com/Itseez/opencv.git