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?

编辑:澄清一下,我知道创建拉请求总是会产生一个新问题。我想把拉请求附加到一个现有的问题上。


当前回答

你可以用Pull Request API从一个已经存在的问题中创建一个Pull Request:

$ curl --user "smparkes" \
       --request POST \
       --data '{"issue": 15, "head": "smparkes:synchrony", "base": "master"}' \
       https://api.github.com/repos/technoweenie/faraday/pulls

这将创建一个拉请求:

询问Faraday project的technoweenie (https://api.github.com/repos/technoweenie/faraday/pulls) 从smparkes的fork中的同步分支中提取("head": "smparkes:synchrony") 到technoweenie's fork中的master分支("base": "master") 并将拉请求附加到issue 15(“issue”:15) 与拉请求作者smparkes(——user "smparkes") 你会被提示输入你的GitHub密码

其他回答

你可以用Pull Request API从一个已经存在的问题中创建一个Pull Request:

$ curl --user "smparkes" \
       --request POST \
       --data '{"issue": 15, "head": "smparkes:synchrony", "base": "master"}' \
       https://api.github.com/repos/technoweenie/faraday/pulls

这将创建一个拉请求:

询问Faraday project的technoweenie (https://api.github.com/repos/technoweenie/faraday/pulls) 从smparkes的fork中的同步分支中提取("head": "smparkes:synchrony") 到technoweenie's fork中的master分支("base": "master") 并将拉请求附加到issue 15(“issue”:15) 与拉请求作者smparkes(——user "smparkes") 你会被提示输入你的GitHub密码

使用git-hub工具,你可以这样做:

$> git枢纽拉附加123

这将把问题#123转换为拉请求#123,从而将关于该问题的所有讨论保持在一个位置。

您也可以使用Gub为您的问题提交拉请求。

它还可以帮助您使用合适的fork/pull-request样式。

编辑:10/5/2013

为了让Gub提交issue #123的pull-request,你需要运行以下命令:

$ gub start 123

这将创建一个新的分支issue-123。一旦你解决了这个问题,执行:

$ gub finish

拖鞋!

注:我是Gub gem的作者。

如果你启用了2FA,你可以使用HTTPie传递令牌:

http POST \
    https://api.github.com/repos/<repo-owner>/<repo-name>/pulls \
    issue=2 head=issue_2 base=master
    "Authorization:token PUTAUTHTOKENHERE"

这将使用分支issue_2将问题#2转换为一个拉请求。

另一个可能的工具是Issue2Pr网站,它可以把你的问题变成Pull Requests。

这非常简单有效!

资源:

公告 GitHub库