How do I check out a remote Git branch?

后端 未结 30 2044
灰色年华
灰色年华 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:29

    OK, the answer is easy... You basically see the branch, but you don't have a local copy yet!...

    You need to fetch the branch...

    You can simply fetch and then checkout to the branch, use the one line command below to do that:

    git fetch && git checkout test
    

    I also created the image below for you to share the differences, look at how fetch works and also how it's different to pull:

提交回复
热议问题