To clone a specific branch, run git branch
with the -b
option and specify the branch to clone.
Syntax:
git clone -b <branch_name> <git_repo_url>
Example : You would run the below command to clone the task1
branch of your Github repository.
git clone -b task1 https://github.com/onnxy/proj.git
Run the git branch
command to cross check that you have cloned the right branch. The branch name should appear if the run the git branch
command.
git branch
task1
Also Read:
How to Clone Git Repository into specific Folder