How to clone all remote branches in Git?

后端 未结 30 2098
情话喂你
情话喂你 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:51

    Use aliases. Though there aren't any native Git one-liners, you can define your own as

    git config --global alias.clone-branches '! git branch -a | sed -n "/\/HEAD /d; /\/master$/d; /remotes/p;" | xargs -L1 git checkout -t'
    

    and then use it as

    git clone-branches
    

提交回复
热议问题