clone & push all remote branches with git

Assuming you have a GIT repository with many branches, it might be little daunting to checkout all the branches as local. This question was also asked in StackOverflow here. This nifty shell script does the job to clone all remote branches locally.

for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do git branch --track ${branch##*/} $branch; done

It will create tracking branches for all remote branches, except master (which you probably got from the original clone command). You might still need to do a -

git fetch --allĀ 
git pull --all

To push all the branches including master -

git push --allĀ 

About C S Shyam Sundar

I'm a thief; I am the will of independence; I am the power of persona; I am the creation of my environment; I am the pursuit of more; I know this, because I thrive on intelligence.

Leave a Reply

Please log in using one of these methods to post your comment:

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 )

Connecting to %s

Stats

  • 142,057 Hits and counting...

Archives

Follow

Get every new post delivered to your Inbox.