How to create a new branch on both local and remote? GIT
This question already has an answer here:
Suppose you already created your local branch (using git branch <branch-name>
or git checkout -b <branch-name>
, you can use:
git push -u origin <branch-name>
explications:
-u
= --set-upstream
: set this new remote branch as tracking branch. origin
: the name of your remote repository First, you create your branch locally:
git checkout -b your_branch
The remote branch is automatically created when you push it to the remote server. So when you feel ready for it, you can just do:
git push <remote-name> <branch-name>
Where <remote-name>
is typically origin
, the name which git gives to the remote you cloned from. Your colleagues would then just pull that branch, and it's automatically created locally.
上一篇: 我如何创建和使用远程git分支?
下一篇: 如何在本地和远程创建新分支? GIT