How do I check out a remote Git branch?

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

    If the branch is on something other than the origin remote I like to do the following:

    $ git fetch
    $ git checkout -b second/next upstream/next
    

    This will checkout the next branch on the upstream remote in to a local branch called second/next. Which means if you already have a local branch named next it will not conflict.

    $ git branch -a
    * second/next
      remotes/origin/next
      remotes/upstream/next
    

提交回复
热议问题