How Do You Clone Down a Specific Branch of a Repository from Git?

Problem scenario
You want to clone a specific branch from Git.  But you do not want to clone the master branch.  How do you clone the branch named "develop"?

Solution
1.  Clone down the repository as normal with a command like this (but replace <SSH or HTTP constructor of repo> with the remote repository):
git clone <SSH or HTTP constructor of repo>

2.  Run this command (you could replace "develop" with the name of the branch you created):  git checkout -b develop

3.  Run this command (you could replace "develop" with the name of the branch you created):  git pull origin develop

Leave a comment

Your email address will not be published. Required fields are marked *