My scrapbook about almost anything I stumble upon in my tech world. If you find anything useful don't forget to give thumbs-up :)

Breaking

Friday, December 11, 2020

Cloning a specific Git Branch

Cloning a specific Git branch is very easy and most of us don't required at all. But this is a very practical ask if your Repository have too many branches or having a big repo with lots of artifacts in it. 
    You can pull / clone a Specific branch these ways - 


1. Older Way (Do not use): 

$ git clone https://github.com/atulsingh0/git-learn.git
$ git checkout develop

The problem with above commands is, It will clone the whole repo with all the branches and then switch to your branch in ask. 

2. Little Better Way (Do not use because its a replica of Older Way): 

$ git clone -b develop https://github.com/atulsingh0/git-learn.git

This is same as Older Way, the only difference is, you need to execute one command rather then two. 

3. New Way:

If you are using git version 1.7 or later, this is the best and sweet command to clone a single branch from git repository.

$ git clone -b develop --single-branch https://github.com/atulsingh0/git-learn.git




Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group     


No comments:

Post a Comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.