How to clone all remote branches in Git?

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

    Here is another short one-liner command which creates local branches for all remote branches:

    (git branch -r | sed -n '/->/!s#^  origin/##p' && echo master) | xargs -L1 git checkout
    

    It works also properly if tracking local branches are already created. You can call it after the first git clone or any time later.

    If you do not need to have master branch checked out after cloning, use

    git branch -r | sed -n '/->/!s#^  origin/##p'| xargs -L1 git checkout
    

提交回复
热议问题