How to clone all remote branches in Git?

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

    Just do this:

    $ git clone git://example.com/myproject
    $ cd myproject
    $ git checkout branchxyz
    Branch branchxyz set up to track remote branch branchxyz from origin.
    Switched to a new branch 'branchxyz'
    $ git pull
    Already up-to-date.
    $ git branch
    * branchxyz
      master
    $ git branch -a
    * branchxyz
      master
      remotes/origin/HEAD -> origin/master
      remotes/origin/branchxyz
      remotes/origin/branch123
    

    You see, 'git clone git://example.com/myprojectt' fetches everything, even the branches, you just have to checkout them, then your local branch will be created.

提交回复
热议问题