Pull specific branch from git

I have a repo in bitbucket, and i am using git.

So my branches are

master
develop_one
develop_two

When i use git clone git@bitbucket.org:project/project.git, i am getting only the master branch code, but i need to clone/pull only develop_one branch, so how to clone/pull only develop_one branch code ?

Note: The other branches(develop_one, develop_two) are not merged in to master, and dont want to merge until the functionality has been completed actually, so want to get/clone/pull only a specific branch code

Answers


Try:

git clone git@bitbucket.org:project/project.git -b develop_one --single-branch

For already cloned repos use:

git fetch
git checkout develop_one
# Or more specific:
git checkout --track -b develop_one

This will track the develop_one branch from the remote.


Also, to add to @tomrbrujin 's answer, you can specify the name of the local destination directory in the clone command like this:

git clone https://github.com/example/example1.git -b branch_name --single-branch local_name

The final arg passed, local_name would create and name the local copy of the cloned remote directory "local_name."

Otherwise, the local directory name will only reflect the repo name, which here would be: example


Need Your Help

maven-surefire-plugin include/exclude precedence

java maven maven-3 pom.xml maven-surefire-plugin

When using the maven-surefire-plugin and both includes and excludes, which order are they processed in? Furthermore, if you have 3 sets of tests, the first being the base set, the second and third...

How to insert a new key with value in dictionary

iphone key nsmutabledictionary

I want to insert a key with a corresponding value in an existing dictionary...