Git Clone Specific Branch-Git Clone Branch Command

Git Clone Specific Branch:

When you are working in a project, you have to work on only specific branches we don’t need to clone entire git repository. So at that time we have to clone a specific branch from git repository. If you clone the entire repository it will occupy more space in your system so this will be useful to save some space in your system. In the following steps i will show you how to clone a specific branch by using git clone branch command.

git clone branch command

by using below command you can clone only specific branch in your git or bit-bucket  repository.

in the place of <Cloning_URL> write your cloning URL of your git or bit bucket repository and in the place of <branch_name> mention your branch name which you want to clone.


git clone -b vijay

here i am cloning vijay branch from my repository.

long-winded way:

What this does is:

here we are creating a directory called abcd. you can name as it your wish and we are going to create an empty git repository in this directory. and we are adding the original repository as a remote called origin. and we are fetching only the branch we require from the remote called origin. after doing git pull you have to checkout to your required branch and there you can see only files of that branch which you cloned.