How do I check out a remote Git branch?

后端 未结 30 1989
灰色年华
灰色年华 2020-11-22 00:12

Somebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r.

<
30条回答
  •  醉话见心
    2020-11-22 00:45

    To clone a Git repository, do:

    git clone 
    

    The above command checks out all of the branches, but only the master branch will be initialized. If you want to checkout the other branches, do:

    git checkout -t origin/future_branch (for example)
    

    This command checks out the remote branch, and your local branch name will be same as the remote branch.

    If you want to override your local branch name on checkout:

    git checkout -t -b enhancement origin/future_branch
    

    Now your local branch name is enhancement, but your remote branch name is future_branch.

提交回复
热议问题