How to clone a specific branch in git bitbucket

89,634

Solution 1

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

Solution 2

git clone -b branchName remote_repo_url

For example git clone -b develop https://github.com/SundeepK/CompactCalendarView.git

Solution 3

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

Solution 4

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.

Solution 5

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.

Share:
89,634

Related videos on Youtube

ruby student
Author by

ruby student

Updated on September 11, 2021

Comments

  • ruby student
    ruby student over 2 years

    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?

  • ruby student
    ruby student about 9 years
  • ruby student
    ruby student about 9 years
    this is my project and I have a branch called validations
  • ruby student
    ruby student about 9 years
    How I clone the whole project and then I after change the branch master to brach validations
  • sfletche
    sfletche about 9 years
    that sounds like a different question...it sounds like you are now wondering how to clone a git project and then create a branch off of master...?
  • ruby student
    ruby student about 9 years
    I want to use the brach validations, but to use validations not master