Reputation: 1129
I want to clone a specific branch. I don't want download the master
branch.
How do I clone the whole project and then switch to validations
branch?
Upvotes: 53
Views: 127470
Reputation: 726
Are you using Sourcetree? If so, select three dots and choose "Checkout in Sourcetree" And then Clone it.
Upvotes: 0
Reputation: 113
Using below command not only you can clone specific branch from origin but also create and checkout locally at same time
To see remote branches do
git branch -r
Then
git checkout -b <local branch name> origin/<branch name>
example: git checkout -b Bug_1 origin/Develop
Upvotes: 1
Reputation: 507
once you're done adding your ssh key, you can follow up with: git clone -b <branch_name> <url_to_repository>
replace all angular brackets with your required branch name and repository URL.
Upvotes: 2
Reputation: 743
To pull a separate branch, you need to follow two simple steps.
1. Create a new branch
2. Pull the required branch
Try using the following commands:
git checkout -b <new-branch-name>
git pull origin <branch-to-pull>
You will now have all the contents in the <new-branch-name>
branch
Upvotes: 12
Reputation: 719
git clone -b branchName remote_repo_url
For example git clone -b develop https://github.com/SundeepK/CompactCalendarView.git
Upvotes: 47
Reputation: 341
Use git clone as following :
git clone -b specific/Branch --single-branch git://sub.domain.com/repo.git
And, Helpful link is
https://git-scm.com/docs/git-clone/1.7.10
Also, If you get an error with "--single-branch", then removed it -b will work for you.
Upvotes: 9
Reputation: 49774
You can clone a single branch (without inadvertently cloning the whole project) with the following:
git clone <url> --branch <branch> --single-branch [<folder>]
Alternatively (attempting to address your new question here...), you can clone the whole project
git clone <url>
Change directories into the folder and creating a new branch off of master with
git checkout -b validations
Upvotes: 47