Make an existing Git branch track a remote branch?

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

    You can do the following (assuming you are checked out on master and want to push to a remote branch master):

    Set up the 'remote' if you don't have it already

    git remote add origin ssh://...
    

    Now configure master to know to track:

    git config branch.master.remote origin
    git config branch.master.merge refs/heads/master
    

    And push:

    git push origin master
    

提交回复
热议问题