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.

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




Leave a Reply

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

You are commenting using your 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