How to clone all remote branches in Git?

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

    You only need to use "git clone" to get all branches.

    git clone 
    

    Even though you only see master branch, you can use "git branch -a" to see all branches.

    git branch -a
    

    And you can switch to any branch which you already have.

    git checkout 
    

    Don't worry that after you "git clone", you don't need to connect with the remote repo, "git branch -a" and "git checkout " can be run successfully when you close your wifi. So it is proved that when you do "git clone", it already has copied all branches from the remote repo. After that, you don't need the remote repo, your local already has all branches' codes.

提交回复
热议问题