简体   繁体   English

如何在github上推送拉取请求?

[英]How do I push to a pull request on github?

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并让它实际上转到pull请求而不是去一个名为pr/2的新分支?

A Pull Request is just a request to merge a certain branch. Pull Request只是合并某个分支的请求。 This means commits made to the branch after the pull request is opened will be included in the eventual merge. 这意味着在打开pull请求之后对分支进行的提交将包含在最终合并中。

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. 如果您有权访问pull请求要求合并的分支,则可以提交到该分支,并且pull请求将随更改一起更新。

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. 现在,您的提交将显示在pull请求中。

Here's are GitHub's "Merging via command line" instructions for pull requests (I am fulldecent, the other guy is ospr): 这是GitHub的“通过命令行合并”拉取请求的指令(我是fulldecent,另一个人是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

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. 即使你能以某种方式改变对你喜欢的引用,github还有其他你无法轻易改变的元数据。 So better push to the branch pull was created from. 因此,更好地推动分支拉动。

$ git push git@github.com: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. 更新:如果您推送到PR所基于的分支/分支,您可以推送到现有的拉取请求。 It is often possible depending on repo settings. 通常可能取决于回购设置。

git push git@github.com:username/repo-name.git localbranchname:remotebranchname

or if you have the fork added as a remote in your local repo, then: 或者如果您在本地仓库中将fork添加为remote ,则:

git push remotename localbranchname:remotebranchname

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. 我是通过我的主分支完成的,但可能你可以创建另一个分支,然后为pull请求创建一个pull请求。 It's all magical to me though with these fancy Git GUIs. 尽管有这些花哨的Git GUI,但这对我来说都很神奇。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM