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?
编辑:澄清一下,我知道创建拉请求总是会产生一个新问题。我想把拉请求附加到一个现有的问题上。
向现有的上游问题添加拉请求很容易,假设您使用正常的github方法进行分叉。
使用任何支持的关键字在提交消息中引用问题:
关闭
关闭
关闭
修复
修复
固定
解决
解决了
解决
例如:"this commit fixes #116"
引用该问题的文本不需要出现在提交的主题行中。
推送你的提交到你的github回购和拉请求将自动追加到问题。
注意:虽然这不是必需的,但强烈建议您将任何作为拉取请求一部分的内容提交到特定于该问题的单独分支,因为在该分支上的未来提交将被追加到拉取请求(由github自动执行)。所以,如果你没有创建一个独立的分支,把它留在master上,然后继续开发,那么所有你对master不相关的提交都会被追加到你的pull request中。
这个答案解释了如何使用cURL (cURL)通过GitHub API从一个问题创建一个拉请求。下面是如何使用HTTPie (http),它产生一个更容易阅读和编辑的命令:
$ http --auth "<your-GitHub-username>" \
POST \
https://api.github.com/repos/<issue-repo-owner>/<issue-repo-name>/pulls \
issue=<issue-number> head=<your-GitHub-username>:<your-fork-branch-name> base=<issue-repo-branch-name>
然后在提示时输入你的GitHub密码。
解释的例子
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:
$ http --auth "smparkes" \
POST \
https://api.github.com/repos/technoweenie/faraday/pulls \
issue=15 head=smparkes:synchrony base=master
http: password for smparkes@api.github.com: hunter2
现在第15个问题是一个Pull Request。