How do you create a remote Git branch?

后端 未结 23 2209
感情败类
感情败类 2020-11-22 13:31

I created a local branch which I want to \'push\' upstream. There is a similar question here on Stack Overflow on how to track a newly created remote branch.

Howeve

23条回答
  •  暖寄归人
    2020-11-22 14:16

    I know this question is well answered, but just wanted to list the steps I take to create a new branch "myNewBranch" and push to remote ("origin" in my case) and set up tracking. Consider this the "TL;DR" version :)

    # create new branch and checkout that branch
    git checkout -b myNewBranch
    # now push branch to remote 
    git push origin myNewBranch
    # set up the new branch to track remote branch from origin
    git branch --set-upstream-to=origin/myNewBranch myNewBranch
    

提交回复
热议问题