Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clone a specific branch in git bitbucket

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?

like image 317
ruby student Avatar asked May 01 '15 02:05

ruby student


People also ask

Can I git clone a specific branch?

There are two ways to clone a specific branch. You can either: Clone the repository, fetch all branches, and checkout to a specific branch immediately. Clone the repository and fetch only a single branch.

How do I clone down a specific branch?

In order to clone a specific branch, you have to execute “git branch” with the “-b” and specify the branch you want to clone. $ git clone -b dev https://github.com/username/project.git Cloning into 'project'... remote: Enumerating objects: 813, done.


1 Answers

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 
like image 159
sfletche Avatar answered Sep 21 '22 18:09

sfletche