How to clone all remote branches in Git?

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

    OK, when you clone your repo, you have all branches there...

    If you just do git branch, they are kind of hidden...

    So if you'd like to see all branches name, just simply add --all flag like this:

    git branch --all or git branch -a

    If you just checkout to the branch, you get all you need.

    But how about if the branch created by someone else after you clone?

    In this case, just do:

    git fetch

    and check all branches again...

    If you like to fetch and checkout at the same time, you can do:

    git fetch && git checkout your_branch_name

    Also created the image below for you to simplify what I said:

提交回复
热议问题