clone & push all remote branches with git

http://thoughtpad.cs3.in/2011/06/13/clone-push-all-remote-branches-with-git/


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 


你可能感兴趣的:(clone & push all remote branches with git)