Git

Clone All Remote Branches With Git

The results I’ll be studying were pushed on 17th Dec. I had a lot of doubts, I cleared them on 18th and then I had to clone all the branches from here. I tried to clone, pull, and fetch, but it remained unable to get anything other than the master branch. This post is about how to clone it all.

 

To explain how to do it, let me take the repo that I worked on:

 

Clone it and cd into it


git clone git@github.com:coccinelle/faults-in-Linux.git

cd faults-in-Linux

 

Look at the local branches in the repo you cloned


git branch

* master

 

But there are some hidden branches too, find them using:


git branch -a

In the case of what we have cloned, you will get:


* master

remotes/origin/HEAD -> origin/master

remotes/origin/edit.hybrid

remotes/origin/master

remotes/origin/orig.org

remotes/origin/v3.16

 

To take a quick peek at an upstream branch, you can check it out directly:


git checkout origin/orig.org

 

To work on that branch, you’ll need to create a local tracking branch:


git checkout -b orig.org origin/orig.org

you will get


Branch orig.org set up to track remote branch orig.org from origin.
Switched to a new branch 'orig.org'

 

Now look at your local branches and you will get


git branch

* orig.org
master

 

 

 

 

……and you are done. 🙂

Advertisements

2 thoughts on “Clone All Remote Branches With Git

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s