git 如何从 GitHub 上的 master 创建开发分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39478482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create development branch from master on GitHub
提问by smeeb
I created a repo on GitHub and only have a master
branch so far. My local working copy is completely up to date with the remote/origin master
on GitHub.
我在 GitHub 上创建了一个 repo,master
到目前为止只有一个分支。我的本地工作副本与master
GitHub 上的 remote/origin 完全同步。
I now want to create a development
branch on GitHub so that other people on my team can start pushing changes to development
(instead of directly to master
) and submit PRs, request code reviews, etc.
我现在想development
在 GitHub 上创建一个分支,以便我团队中的其他人可以开始将更改推送到development
(而不是直接推送到master
)并提交 PR、请求代码等。
So I tried creating a new development
branch locally and pushing it:
所以我尝试development
在本地创建一个新分支并推送它:
git checkout -b development
git push origin development:master
But git just says Everything up-to-date
. So I ask:
但是 git 只是说Everything up-to-date
. 所以我问:
If I'm current with master
, how do I just create a remote development
branch that contains an exact copy of master
?
如果我现在使用master
,我如何只创建一个development
包含精确副本的远程分支master
?
回答by ddavison
When you do
当你做
$ git push origin development:master
What's actually happening is git is taking <local>:<remote>
and updating <remote>
to whatever the <local>
branch is.
实际发生的是 git 正在获取<local>:<remote>
并更新<remote>
到任何<local>
分支。
Since you executed git checkout -b development
from master
, your local development
has all the commits master
does; hence it shows as everything is up to date.
由于您git checkout -b development
从执行master
,您的本地development
拥有所有提交master
;因此它显示一切都是最新的。
You can just do
你可以做
$ git checkout -b development
$ git push origin development
to push the new branch
推送新分支
回答by Kabard
This works for me
这对我有用
git push origin development
回答by williamdelgato
You can also use git flow. This will automatically create the branch with the right naming convention, it's good practice.
您也可以使用 git flow。这将自动创建具有正确命名约定的分支,这是一种很好的做法。
git flow init
and to push
并推
git push --set-upstream origin develop