How do you create a remote Git branch?

后端 未结 23 2155
感情败类
感情败类 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条回答
  •  旧时难觅i
    2020-11-22 14:17

    I've solved this by adding this into my bash ~/.profile:

    function gitb() { git checkout -b $1 && git push --set-upstream origin $1; }

    Then to start up a new local + remote branch, I write:

    gitb feature/mynewbranch

    This creates the branch and does the first push, not just to setup tracking (so that later git pull and git push work without extra arguments), but actually confirming that the target repo doesn't already have such branch in it.

提交回复
热议问题