Make an existing Git branch track a remote branch?

前端 未结 22 3692
执念已碎
执念已碎 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:09

    1- update your local meta-data using : git fetch --all

    2- show your remote and local branches using : git branch -a , see the following Screenshot

    3- switch to target branch , that you want to linked with the remote: using

    git checkout branchName

    example :

    4- Link your local branch to a remote branch using:

    git branch --set-upstream-to nameOfRemoteBranch

    N.B : nameOfRemoteBranch : to copy from the output of step 2 " git branch -r "

    Example of use:

提交回复
热议问题