我创建了一个本地分支。如何将其推送到远程服务器?
更新:我在这里为Git2.0写了一个更简单的答案。
我创建了一个本地分支。如何将其推送到远程服务器?
更新:我在这里为Git2.0写了一个更简单的答案。
当前回答
如果你想创建远程分支而不需要本地分支,你可以这样做:
git push origin HEAD:refs/heads/foo
它将您的HEAD推送到远程上不存在的分支foo。
其他回答
现在使用git,当您在正确的分支中时,您只需键入
git push—设置上游起点<远程分支名称>
git为您创建原始分支。
如果已使用--single branch克隆当前分支,请使用此命令从当前分支创建新分支:
git checkout -b <new-branch-name>
git push -u origin <new-branch-name>
git remote set-branches origin --add <new-branch-name>
git fetch
从Git2.37.0开始,您不再需要“--setupstreamorigin”。只要按一下。您可以通过启用push.autoSetupRemote选项来实现这一点
git-config--global--add--bool push.autoSetupRemote true
你可以简单地,
git结帐-b YOUR-NEW-BRANCH-NAMEgit添加。git推送原点YOUR-NEW-BRANCH-NAME
您可以在相关git repo下看到您的分行代码
干杯!!:)
首先在本地创建分支:
git checkout -b your_branch
然后远程创建分支:
git push --set-upstream origin your_branch
注意:这适用于git的最新版本:
$ git --version
git version 2.3.0
干杯