Monday, 23 November 2015

How to clone single branch from the GitHub?

Generally GitHub repository has multiple branch on it. But sometime we don't want to clone whole branch.

This command "git clone git://github/repository.git" will take all branches of its. But we want to only clone "Sub_Branch_2" branch.

For Example:

Main_Branch
        '
        ' - > Sub_Branch_1
       
        '
        ' - > Sub_Branch_2
       
        '
        ' - > Sub_Branch_3
 

This blog will help you for cloning single branch from GitHub.

First we need to check system git version using below command.

git --version

If git version is less than 1.8.x than we must to upgrade git version using below command.

sudo add-apt-repository ppa:pdoes/ppa
sudo apt-get update
sudo apt-get install git
git --version

Afterwards use below command for clone single branch

git clone -b branch_name --single-branch git://github/repository.git

For example:

git clone -b Sub_Branch_2 --single-branch git://github/repository.git

For more details, you may visit Git tutorial

I hope you like this article. Share your views to improve content. Happy Learning !!!

No comments:

Post a Comment

ImportError: cannot import name 'utils' from 'PyPDF2'

Odoo 15: Traceback (most recent call last):   File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner     self...