How to clone all remote branches in Git?

后端 未结 30 2101
情话喂你
情话喂你 2020-11-22 01:08

I have a master and a development branch, both pushed to GitHub. I\'ve cloned, pulled, and fetched, but I re

30条回答
  •  终归单人心
    2020-11-22 01:35

    Looking at one of answers to the question I noticed that it's possible to shorten it:

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

    But beware, if one of remote branches is named as e.g. admin_master it won't get downloaded!

    Thanks to bigfish for original idea

提交回复
热议问题