Make an existing Git branch track a remote branch?

前端 未结 22 3034
执念已碎
执念已碎 2020-11-21 07:16

I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch?

I know I can just edit the

22条回答
  •  我寻月下人不归
    2020-11-21 08:07

    I use the following command (Suppose your local branch name is "branch-name-local" and remote branch name is "branch-name-remote"):

    $ git branch --set-upstream-to=origin/branch-name-remote branch-name-local
    

    If both local and remote branches have the same name, then just do the following:

    $ git branch --set-upstream-to=origin/branch-name branch-name
    

提交回复
热议问题