git 如何推送到 github 上的拉取请求?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15530510/
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 do I push to a pull request on github?
提问by lobati
I've added this to my .git/config
file:
我已将此添加到我的.git/config
文件中:
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
Which allows me to pull down pull request diffs, but when I check it out it actually creates a branch with that same name. Is there any way for me to push to pr/2
and have it actually go to the pull request instead of going to a new branch named pr/2
?
这允许我拉下拉取请求差异,但是当我检查它时,它实际上创建了一个具有相同名称的分支。有什么方法可以让我推送pr/2
并让它真正转到拉取请求而不是转到名为 的新分支pr/2
?
回答by Ross
A Pull Request is just a request to merge a certain branch. This means commits made to the branch after the pull request is opened will be included in the eventual merge.
拉取请求只是合并某个分支的请求。这意味着在拉取请求打开后对分支进行的提交将包含在最终合并中。
If you have access to the branch that the pull request is asking to merge, you can commit to that branch and the pull request will update with the changes.
如果您有权访问拉取请求要求合并的分支,您可以提交到该分支,拉取请求将随更改更新。
Example:
例子:
pull/3 is requesting to merge hotfix
into master
pull/3 请求合并hotfix
到master
git fetch
git checkout hotfix
git pull origin hotfix
make changes
做出改变
git add .
git commit -m "changes!"
git push origin hotfix
Now your commit will show up in the pull request.
现在您的提交将显示在拉取请求中。
回答by William Entriken
Here's are GitHub's "Merging via command line" instructions for pull requests (I am fulldecent, the other guy is ospr):
这是 GitHub 的“通过命令行合并”的拉取请求说明(我很体面,另一个人是 ospr):
Step 1: From your project repository, check out a new branch and test the changes.
步骤 1:从您的项目存储库中,签出一个新分支并测试更改。
git checkout -b ospr-image-rendering master
git pull https://github.com/ospr/FDWaveformView.git image-rendering
Step 2: Merge the changes and update on GitHub.
第 2 步:在 GitHub 上合并更改和更新。
git checkout master
git merge --no-ff ospr-image-rendering
git push origin master
Here is the additional step that sends your changes back upstream(?) to the PR originator.
这是将您的更改发回上游(?)给 PR 发起人的附加步骤。
git push https://github.com/ospr/FDWaveformView.git ospr-image-rendering:image-rendering
回答by akostadinov
Good question. But I would be surprised if you could:
好问题。但如果你能:
$ cat .git/refs/pull/upstream/839
f8a9f492098e154b4a8258a941af47c9ca017ada
Even if you can somehow change that reference to what you like, github has other metadata that you can't easily change. So better push to the branch pull was created from.
即使您可以以某种方式将该引用更改为您喜欢的内容,github 也有其他您无法轻松更改的元数据。所以更好地推送到分支 pull 是从创建的。
$ git push [email protected]:owner/repo.git HEAD:target-branch
See the github command line wrapper for easier github interaction from command line: https://hub.github.com/
请参阅 github 命令行包装器,以便从命令行更轻松地进行 github 交互:https: //hub.github.com/
Update: You can push to an existing pull request if you push to the fork/branch that PR is based on. It is often possible depending on repo settings.
更新:如果您推送到 PR 所基于的分支/分支,您可以推送到现有的拉取请求。根据回购设置,这通常是可能的。
git push [email protected]:username/repo-name.git localbranchname:remotebranchname
or if you have the fork added as a remote
in your local repo, then:
或者,如果您remote
在本地存储库中添加了 fork ,则:
git push remotename localbranchname:remotebranchname
回答by carlin.scott
The GitHub Desktop client will create another pull request (PR) that includes the original PR and your changes if you try to merge changes to a PR you checked out.
如果您尝试将更改合并到您签出的 PR,GitHub 桌面客户端将创建另一个拉取请求 (PR),其中包含原始 PR 和您的更改。
I did this off of my master branch but presumably you could make another branch and then create a pull request to the pull request. It's all magical to me though with these fancy Git GUIs.
我在我的主分支上做了这个,但大概你可以创建另一个分支,然后创建一个拉请求到拉请求。尽管这些花哨的 Git GUI 对我来说都很神奇。