How to clone all remote branches in Git?

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

    The fetch that you are doing should get all the remote branches, but it won't create local branches for them. If you use gitk, you should see the remote branches described as "remotes/origin/dev" or something similar.

    To create a local branch based on a remote branch, do something like:

    git checkout -b dev refs/remotes/origin/dev

    Which should return something like:

    Branch dev set up to track remote branch refs/remotes/origin/dev.
    Switched to a new branch "dev"

    Now, when you are on the dev branch, "git pull" will update your local dev to the same point as the remote dev branch. Note that it will fetch all branches, but only pull the one you are on to the top of the tree.

提交回复
热议问题