How do I push a new local branch to a remote Git r

2018-12-31 19:06发布

I want to be able to do the following:

  1. Create a local branch based on some other (remote or local) branch (via git branch or git checkout -b)

  2. Push the local branch to the remote repository (publish), but make it trackable so git pull and git push will work immediately.

How do I do that?

I know about --set-upstream in Git 1.7, but that is a post-creation action. I want to find a way to make a similar change when pushing the branch to the remote repository.

13条回答
姐姐魅力值爆表
2楼-- · 2018-12-31 20:05

Simply put, to create a new local branch, do:

git branch <branch-name>

To push it to the remote repository, do:

git push -u origin <branch-name>
查看更多
登录 后发表回答