我不确定,但我有一个模糊的记忆,创建了一个带有“Issue 4”或标题中的内容的 github pull request,并且它自动附加到我提交的项目中的 Issue 4。我最近又尝试了一次,但没有成功——它只是创建了一个全新的问题。我在新的拉取请求页面上没有看到任何类似“附加到问题”的选项,也没有在问题页面上看到“为此问题打开新的拉取请求”。有什么方法可以做到这一点,以帮助项目所有者保持问题页面整洁并避免重复?
编辑:澄清一下,我知道创建拉取请求总是会产生新问题。我想将拉取请求附加到现有问题。
I'm not sure, but I have a vague memory of creating a github pull request with "Issue 4" or something in the title, and it automatically attached itself to Issue 4 in the project that I was submitting it to. I tried it again recently and it didn't work -- it just created a brand new issue instead. I don't see any options like "Attach to issue" on the new pull request page, nor "Open a new pull request for this issue" on the issue page. Is there any way to do this, to help project owners keep their Issues page clean and avoid duplication?
Edit: To clarify, I know that creating a pull request always creates a new issue. I would like to instead attach the pull request to an existing issue.
发布评论
评论(10)
向现有上游问题添加拉取请求很容易假设您使用正常的 github 方式进行分叉。
只需使用任何支持的关键字在提交消息中引用该问题:
例如:“此提交修复#116”
引用该问题的文本不需要出现在提交的主题行中。
将您的提交推送到 github 存储库,拉取请求将自动附加到问题中。
注意:虽然不是必需的,但强烈建议您将属于拉取请求一部分的任何内容提交到特定于该问题的单独分支,因为该分支上的未来提交将被附加到拉取请求(由 github 自动添加) )。因此,如果您没有创建单独的分支,将其保留在 master 上,然后继续开发,那么您对 master 的所有不相关的提交都将被附加到您的拉取请求中。
Adding a pull request to an existing upstream issue is easy assuming you forked using the normal github means.
Simply reference the issue in your commit message using any of the supported keywords:
For example: "this commit fixes #116"
The text referencing the issue does not need to appear in the subject line of your commit.
Push your commit to your github repo and the pull request will be automatically appended to the issue.
Note: While it is not required, it is strongly recommended that you commit anything that will be part of a pull request to a separate branch specific to that issue, because future commits on that branch will be appended to the pull request (automatically by github). So, if you didn't make a separate branch, left it on master, and then kept developing, then all your unrelated commits to master would get appended to your pull request.
hub 项目可以做到这一点。
在要从中发送拉取请求的存储库和分支中:
这使用 GitHub API,并将当前分支的拉取请求附加到现有问题号 4。
编辑:@atomicules 的评论:为了扩展 @MichaelMior 的答案,一个完整的例子是:
The hub project can do this.
In the repository and branch that you want to send a pull request from:
This uses the GitHub API, and attaches a pull request for the current branch to the existing issue number 4.
EDIT: Comment by @atomicules: To expand on the answer by @MichaelMior a full example is:
您可以使用 Pull Request API 从现有问题创建 Pull 请求:
这会创建一个拉取请求:
faraday
项目中询问technoweenie
(https://api.github.com/repos/technoweenie /faraday/pulls)smparkes
' fork 中的synchrony
分支中拉取(“head ": "smparkes:同步")master
分支>technoweenie 的 fork ("base": "master")smparkes
(--user“smparkes”),系统You can create a Pull Request from an existing Issue with the Pull Request API:
This creates a pull request:
technoweenie
at projectfaraday
(https://api.github.com/repos/technoweenie/faraday/pulls)synchrony
branch insmparkes
' fork ("head": "smparkes:synchrony")master
branch intechnoweenie
's fork ("base": "master")smparkes
(--user "smparkes")另一个可能的工具是 Issue2Pr 网站,它将您的问题转化为拉取请求。
非常简单有效!
资源:
Another possible tool is the Issue2Pr website which turns your issues into Pull Requests.
It's very simple and effective!
Resources:
这个其他答案解释了如何使用cURL (
curl
) 通过 GitHub API。以下是如何使用 HTTPie (http
) 来完成此操作,这会产生更简单的- 易于阅读且易于编辑的命令:然后在出现提示时输入您的 GitHub 密码。
解释示例
您已使用用户名 smparkes 和密码 hunter2< 登录 GitHub /em>.您看到了 technoweenie 的存储库 faraday,想到了应该更改的内容,并在该存储库上为其提出了一个问题,问题#15。后来,你发现没有其他人做出你提议的改变,而你也有一些时间自己去做。您分叉faraday到您自己的帐户,然后写入您的更改并推送它们到名为 synchrony 的分支下的分支。您认为 technoweenie 应该将这些更改拉到 master 他的仓库的分支。对于这种情况,您可以编写以下命令,将之前的问题转换为拉取请求:
现在 问题#15 是一个 Pull 请求。
This other answer explains how to use cURL (
curl
) to create a Pull Request from an Issue through the GitHub API. Here’s how to do it using HTTPie (http
), which produces an easier-to-read and easier-to-edit command:Then type your GitHub password when prompted.
Explained example
You have logged into GitHub with username smparkes and password hunter2. You saw technoweenie’s repo faraday, thought of something that should be changed, and made an Issue on that repo for it, Issue #15. Later, you find that nobody else has made your proposed change, and you also have some time to do it yourself. You fork faraday to your own account, then write your changes and push them to your fork under a branch named synchrony. You think technoweenie should pull those changes to the master branch of his repo. This is the command you would write to convert your previous Issue into a Pull Request for this situation:
Now Issue #15 is a Pull Request.
而不是在客户端执行此操作(使用
hub
,如 < a href="https://stackoverflow.com/users/3757/christian-oudard">克里斯蒂安·乌达尔 答案),您现在(2020 年 2 月)可以在服务器端 (github.com) 执行此操作,请参阅“从侧边栏查看和链接问题和拉取请求 "
文档:
还有一个 搜索 API 具有该功能。
Ismoh 指评论到讨论:
“GitHub Action: Pull request 'development' object/data, aka linked issues"
和 Ismosh 的 用于查找拉取请求的链接问题的市场操作。
Instead of doing that on the client side (with
hub
, as in Christian Oudard answer), you now (February 2020) can do it on the server side (github.com)See "View and link issues and pull requests from the sidebar "
Documentation:
And there is a search API with that feature.
Ismoh refers in the comments to the discussion:
"GitHub Action: Pull request 'development' object/data, aka linked issues"
And Ismosh's Marketplace action for finding the linked issues of a pull request.
如果您在 github 上使用 2-factor-auth,您需要在请求中提供 authtoken 作为标头:
in case you use 2-factor-auth with github you'll need to provide the authtoken as header in the request:
您还可以使用 Gub 提交针对您的问题的拉取请求。
它还可以帮助您使用正确的分叉/拉请求样式。
编辑:2013 年 10 月 5 日
要让 Gub 提交问题 #123 的拉取请求,您需要运行以下命令:
这将创建一个新的分支 issues-123。一旦你完成了这个问题,执行:
瞧!
注:我是Gub gem 的作者。
You may also use Gub to submit pull requests for your issue.
It also helps you use a proper fork/pull-request style.
Edit: 10/5/2013
To get Gub to submit pull-request for issue #123, you need to run the following:
This will create a new branch issue-123. Once you're done working on the issue, execute:
Voila!
Note: I am the author of Gub gem.
使用 git-hub 工具,您可以通过以下方式执行此操作:
$>; git hub 拉附加 123
这会将问题 #123 转换为拉取请求 #123,从而将有关该问题的所有讨论保留在一个位置。
Using the git-hub tool, you could do this with:
$> git hub pull attach 123
This would convert issue #123 into pull request #123, thus maintaining all discussion about the issue in a single location.
如果您启用了 2FA,则可以使用 HTTPie 传递令牌:
这将使用分支
issue_2
将问题 #2 转换为拉取请求。If you have 2FA enabled, you can use pass the token with HTTPie:
This will use the branch
issue_2
to convert issue #2 into a pull request.