git 推送到远程分支以进行拉取请求
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35184661/
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
Pushing to remote branch for pull request
提问by Em Ae
I am lost in different articles and stackoverflow questions and I am unable to put my head around to figure out the command for GIT. Here is what i want to do
我在不同的文章和 stackoverflow 问题中迷失了方向,我无法集中精力找出 GIT 的命令。这是我想要做的
- I created the branch from master using eclipse Git.
- I switched to that branch
- Made my changes
- 我使用 eclipse Git 从 master 创建了分支。
- 我切换到那个分支
- 做了我的改变
Now, I want to
现在,我想
- Commit changes locally (`git commit -m "comment"')
- Push to repository as branch of the
Master
so that i can create thepull request
. Once pull approved it will bemerged
into the master. But how would i push my local to upstream so that the branch is created and i can issue pull request ?
- 在本地提交更改(`git commit -m "comment"')
- 推送到存储库作为 的分支,
Master
以便我可以创建pull request
. 一旦拉动批准,它将merged
进入主人。但是我如何将我的本地推送到上游,以便创建分支并且我可以发出拉取请求?
回答by Kevin Burdett
Git has no concept of pull requests, so if you are using Git proper then you merely need to push your local branch to the remote (typically called origin).
Git 没有拉取请求的概念,因此如果您正确使用 Git,那么您只需要将本地分支推送到远程(通常称为源)。
git push -u origin my-branch-name
This will push the branch "my-branch-name" to the origin remote. The "-u" argument will set the upstream branch for you so that future pushes can be done with just "git push". At this point, others can see and review it (if you wish) before you merge it to master, like so:
这会将分支“my-branch-name”推送到远程源。“-u”参数将为您设置上游分支,以便将来可以仅使用“git push”来完成推送。此时,其他人可以在将其合并到 master 之前查看并查看它(如果您愿意),如下所示:
git checkout master
git merge my-branch-name
git push
If you are talking about GitHub, the workflow is slightly different. You need to
如果您在谈论 GitHub,则工作流程略有不同。你需要
- Fork the repository on GitHub
- Clone a copy of your fork
- Create your branch
- Commit your changes
- Push your changes to the fork
- Initiate the Pull Request from your fork in GitHub
- 在 GitHub 上分叉存储库
- 克隆你的叉子的副本
- 创建你的分支
- 提交您的更改
- 将您的更改推送到 fork
- 从 GitHub 中的 fork 发起拉取请求
GitHub has a lot of good documentation around this: https://help.github.com/categories/collaborating-on-projects-using-pull-requests/
GitHub 有很多关于这个的很好的文档:https: //help.github.com/categories/collaborating-on-projects-using-pull-requests/