Checkout branch on different remote

前端 未结 3 844
难免孤独
难免孤独 2021-02-06 23:22

I have a repo that has another remote upstream besides origin. I can do git checkout origin/master, but when I run git checkout upst

3条回答
  •  梦如初夏
    2021-02-07 00:13

    In more concise way (I'm using git 2.28), you can say

    git fetch upstream
    

    and then

    git checkout -b  --guess
    

    where the --guess flag checks if a branch corresponding to exists on any of the remotes and tracks the corresponding remote (docs here).

提交回复
热议问题