git 您如何将新的拉取请求附加到 github 上的现有问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4528869/
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 you attach a new pull request to an existing issue on github?
提问by MatrixFrog
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?
我不确定,但我对创建带有“问题 4”或标题中的内容的 github 拉取请求有模糊的记忆,并且它自动将自己附加到我提交的项目中的问题 4。我最近又试了一次,但没有用——它只是创建了一个全新的问题。我在新的拉取请求页面上看不到任何选项,例如“附加到问题”,也没有在问题页面上看到“为此问题打开新的拉取请求”。有没有办法做到这一点,以帮助项目所有者保持他们的问题页面干净并避免重复?
Edit: To clarify, I know that creating a pull request always creates a newissue. I would like to instead attach the pull request to an existingissue.
编辑:澄清一下,我知道创建拉取请求总是会产生一个新问题。我想将拉取请求附加到现有问题。
采纳答案by Christian Oudard
The "hub" project can do this:
“集线器”项目可以这样做:
https://github.com/defunkt/hub
https://github.com/defunkt/hub
In the repository and branch that you want to send a pull request from:
在要从中发送拉取请求的存储库和分支中:
$ hub pull-request -i 4
This uses the GitHub API, and attaches a pull request for the current branch to the existing issue number 4.
这使用 GitHub API,并将当前分支的拉取请求附加到现有问题编号 4。
EDIT:Comment by @atomicules: To expand on the answer by @MichaelMior a full example is:
编辑:@atomicules 的评论:要扩展@MichaelMior 的答案,一个完整的例子是:
$ hub pull-request -i 4 -b USERNAME_OF_UPSTREAM_OWNER:UPSTREAM_BRANCH -h YOUR_USERNAME:YOUR_BRANCH URL_TO_ISSUE
回答by masukomi
Adding a pull request to an existing upstream issue is easy assuming you forked using the normal github means.
假设您使用普通的 github 方法分叉,则向现有的上游问题添加拉取请求很容易。
Simply reference the issue in your commit message using any of the supported keywords:
只需使用任何受支持的关键字在提交消息中引用问题:
- close
- closes
- closed
- fix
- fixes
- fixed
- resolve
- resolves
- resolved
- 关闭
- 关闭
- 关闭
- 使固定
- 修复
- 固定的
- 解决
- 解决
- 解决
For example: "this commit fixes #116"
例如:“此提交修复了 #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.
将您的提交推送到您的 github 存储库,拉取请求将自动附加到问题中。
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.
注意:虽然不是必需的,但强烈建议您将拉取请求中的任何内容提交到特定于该问题的单独分支,因为该分支上的未来提交将附加到拉取请求中(由 github 自动执行) )。所以,如果你没有创建一个单独的分支,把它留在 master 上,然后继续开发,那么你对 master 的所有无关提交都会附加到你的拉取请求中。
回答by technoweenie
You can create a Pull Request from an existing Issue with the Pull Request API:
$ curl --user "smparkes" \
--request POST \
--data '{"issue": 15, "head": "smparkes:synchrony", "base": "master"}' \
https://api.github.com/repos/technoweenie/faraday/pulls
This creates a pull request:
这会创建一个拉取请求:
- ask
technoweenie
at projectfaraday
(https://api.github.com/repos/technoweenie/faraday/pulls) - to pull from the
synchrony
branch insmparkes
' fork ("head": "smparkes:synchrony") - to the
master
branch intechnoweenie
's fork ("base": "master") - and attach the pull request to issue 15 ("issue": 15)
- with the pull request author
smparkes
(--user "smparkes") - you will be prompted for your GitHub password
- 问
technoweenie
在项目faraday
(https://api.github.com/repos/ technoweenie/法拉第/拉) - 从'叉子的
synchrony
分支中拉出smparkes
(“头”:“ smparkes:同步”) - 到
master
分叉中technoweenie
的分支(“base”:“ master”) - 并将拉取请求附加到 issue 15 ("issue": 15)
- 与拉取请求作者
smparkes
(--user“ smparkes”) - 系统将提示您输入 GitHub 密码
回答by nulltoken
Another possible tool is the Issue2Pr websitewhich turns your issues into Pull Requests.
另一个可能的工具是Issue2Pr 网站,它将您的问题转化为拉取请求。
It's very simple and effective!
这是非常简单和有效的!
Resources:
资源:
回答by Rory O'Kane
This other answerexplains 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:
这个另一个答案解释了如何使用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>
Then type your GitHub password when prompted.
然后在出现提示时输入您的 GitHub 密码。
Explained example
解释示例
You have logged into GitHub with username smparkesand 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 faradayto your own account, then write your changes and push them to your fork under a branch named synchrony. You think technoweenieshould pull those changes to the masterbranch of his repo. This is the command you would write to convert your previous Issue into a Pull Request for this situation:
您已使用用户名smparkes和密码Hunter2登录到 GitHub 。你看到technoweenie的回购法拉第,想到的东西应该被改变,对回购做出一个问题吧,问题#15。后来,您发现没有其他人做出了您提出的更改,而您也有一些时间自己做。您将faraday分叉到您自己的帐户,然后写下您的更改并将它们推送到名为Synchrony的分支下的您的分叉中。您认为technoweenie应该将这些更改拉到master他的回购的分支。这是您将编写的命令,用于将您之前的问题转换为这种情况下的拉取请求:
$ http --auth "smparkes" \
POST \
https://api.github.com/repos/technoweenie/faraday/pulls \
issue=15 head=smparkes:synchrony base=master
http: password for [email protected]: hunter2
Now Issue #15is a Pull Request.
现在问题 # 15是一个拉取请求。
回答by J?rn Hees
in case you use 2-factor-auth with github you'll need to provide the authtoken as header in the request:
如果您在 github 中使用 2-factor-auth,则需要在请求中提供 authtoken 作为标头:
curl -u "<your_username>:<your_pw>" \
--header 'X-GitHub-OTP: <your_authtoken>' \
--request POST \
--data '{"issue":"<issue_nr>", "head":"<your_username>:<your_forks_branchname>", "base":"<upstream_branch>"}' \
https://api.github.com/repos/<upstream_user>/<upstream_repo>/pulls
回答by Omar Ali
You may also use Gubto submit pull requests for your issue.
您还可以使用Gub为您的问题提交拉取请求。
It also helps you use a proper fork/pull-request style.
它还可以帮助您使用正确的 fork/pull-request 样式。
Edit: 10/5/2013
编辑:10/5/2013
To get Gub to submit pull-request for issue #123, you need to run the following:
要让 Gub 提交问题 #123 的拉取请求,您需要运行以下命令:
$ gub start 123
This will create a new branch issue-123. Once you're done working on the issue, execute:
这将创建一个新的分支 issue-123。完成问题的处理后,执行:
$ gub finish
Voila!
瞧!
Note: I am the author of Gub gem.
注意:我是 Gub gem 的作者。
回答by VonC
Instead of doing that on the client side (with hub
, as in Christian Oudardanswer), you now (February 2020) can do it on the serverside (github.com)
您现在(2020 年 2 月)可以在服务器端 (github.com)执行此操作,而不是在客户端执行此操作(使用hub
,如Christian Oudard 的回答)
See "View and link issues and pull requests from the sidebar "
请参阅“从侧边栏查看和链接问题以及拉取请求”
You can now link issues and pull requests via the sidebar in their respective pages. Connections made here will automatically close issues once a linked pull request is merged.
您现在可以通过各自页面中的侧边栏链接议题和拉取请求。一旦链接的拉取请求被合并,在此处建立的连接将自动关闭问题。
文件:
And there is a search APIwith that feature.
并且有一个具有该功能的搜索 API。
Find all the open issues in a repository that have closing pull requests references with the
linked:pr
search qualifier.
Similarly, locate all the pull requests in a repository that are missing a supporting issue with-linked:issue
.
使用
linked:pr
搜索限定符查找存储库中具有关闭拉取请求引用的所有未解决问题。
同样,在存储库中找到所有缺少支持问题的拉取请求-linked:issue
。
回答by Gautam
回答by Kyle Gibson
If you have 2FA enabled, you can use pass the token with HTTPie:
如果您启用了 2FA,您可以使用 HTTPie 传递令牌:
http POST \
https://api.github.com/repos/<repo-owner>/<repo-name>/pulls \
issue=2 head=issue_2 base=master
"Authorization:token PUTAUTHTOKENHERE"
This will use the branch issue_2
to convert issue #2 into a pull request.
这将使用分支issue_2
将问题 #2 转换为拉取请求。