Make an existing Git branch track a remote branch?

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

    or simply by :

    switch to the branch if you are not in it already:

    [za]$ git checkout branch_name
    

    run

    [za]$ git branch --set-upstream origin branch_name
    Branch origin set up to track local branch brnach_name by rebasing.
    

    and you ready to :

     [za]$ git push origin branch_name
    

    You can alawys take a look at the config file to see what is tracking what by running:

     [za]$ git config -e
    

    It's also nice to know this, it shows which branches are tracked and which ones are not. :

      [za]$ git remote show origin 
    

提交回复
热议问题