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?
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
git clone -b branchName remote_repo_url
例如git clone -b develop https://github.com/SundeepK/CompactCalendarView.git
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
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.
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.