我创建了一个本地分支。如何将其推送到远程服务器?
更新:我在这里为Git2.0写了一个更简单的答案。
我创建了一个本地分支。如何将其推送到远程服务器?
更新:我在这里为Git2.0写了一个更简单的答案。
当前回答
如何通过源树进行操作
1: Open SourceTree, click on Repository -> Checkout
2: Click on Create New Branch
3: Select the branch where you want to get code for new branch
4: Give your branch name
5: Push the branch (by click on Push-button)
其他回答
在本地计算机上创建分支并在此分支中切换:
$ git checkout -b [name_of_your_new_branch]
推动github上的分支:
$ git push origin [name_of_your_new_branch]
当你想在你的分支中提交一些事情时,一定要在你的分行中。
您可以看到使用以下方法创建的所有分支:
$ git branch
将显示:
* approval_messages
master
master_clean
为分支添加新的远程:
$ git remote add [name_of_your_remote]
将提交中的更改推送到分支中:
$ git push origin [name_of_your_remote]
更新官方存储库中的原始分支后,更新分支:
$ git fetch [name_of_your_remote]
然后,您需要申请合并更改,如果您的分支是从开发派生的,则需要执行以下操作:
$ git merge [name_of_your_remote]/develop
删除本地文件系统上的分支:
$ git branch -d [name_of_your_new_branch]
要强制删除文件系统上的本地分支,请执行以下操作:
$ git branch -D [name_of_your_new_branch]
删除github上的分支:
$ git push origin :[name_of_your_new_branch]
此处显示所有信息
其他现有项目
如前面的回答中所述,
git push <remote-name> <local-branch-name>:<remote-branch-name>
足以推动本地分支。
您的同事可以使用以下命令拉动所有远程分支(包括新分支):
git remote update
然后,要对分支进行更改,通常的流程如下:
git checkout -b <local-branch-name> <remote-name>/<remote-branch-name>
首先在本地创建分支:
git checkout -b your_branch
然后远程创建分支:
git push --set-upstream origin your_branch
注意:这适用于git的最新版本:
$ git --version
git version 2.3.0
干杯
如何通过源树进行操作
1: Open SourceTree, click on Repository -> Checkout
2: Click on Create New Branch
3: Select the branch where you want to get code for new branch
4: Give your branch name
5: Push the branch (by click on Push-button)
从Git2.37.0开始,您不再需要“--setupstreamorigin”。只要按一下。您可以通过启用push.autoSetupRemote选项来实现这一点
git-config--global--add--bool push.autoSetupRemote true