How to clone all git remote branches as well with master one

While I was working on a project where we have lots of git branch created (around 21 branches) and I want to clone them all at once at my pc, then I came to solution to have a small bash script that one can run after cloning the repo. This bash script will automatically cloned  all remote branches. So it save one from  wasting a good amount of time to clone each branch separately.

Below is the script.

#!/bin/bash
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`;
do
echo cloning branch $branch
git branch –track ${branch#remotes/origin/} $branch
done

 

 

Advertisements

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