How do you attach a new pull request to an existing issue on github? How do you attach a new pull request to an existing issue on github? git git

How do you attach a new pull request to an existing issue on github?


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:

  • close
  • closes
  • closed
  • fix
  • fixes
  • fixed
  • resolve
  • resolves
  • resolved

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.


The "hub" project can do this:

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.


EDIT: Comment by @atomicules: To expand on the answer by @MichaelMior a full example is:

$ hub pull-request -i 4 -b USERNAME_OF_UPSTREAM_OWNER:UPSTREAM_BRANCH -h YOUR_USERNAME:YOUR_BRANCH URL_TO_ISSUE


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 project faraday (https://api.github.com/repos/technoweenie/faraday/pulls)
  • to pull from the synchrony branch in smparkes' fork ("head": "smparkes:synchrony")
  • to the master branch in technoweenie'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