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 -


push to another url
git remote add ALIAS USERNAME@IP-ADDRESS:/PATH/REPO.git
git push ALIAS --all 


push to origin url
git push --all


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

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