How do I check out a remote Git branch?

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

    This will DWIM for a remote not named origin (documentation):

    $ git checkout -t remote_name/remote_branch
    

    To add a new remote, you will need to do the following first:

    $ git remote add remote_name location_of_remote
    $ git fetch remote_name
    

    The first tells Git the remote exists, the second gets the commits.

提交回复
热议问题