Attach a Pull Request to an Existing GitHub Issue

This page has been translated into Spanish language by Maria Ramos from

GitHub users may have this experience: after reporting an issue for a project on GitHub, you suddenly found a solution to fix it. Then you want to attach a pull request to this issue, but by the time this article is written, GitHub does not provide a web interface to attach a pull request to an issue. However, no such web interface does not mean it's impossible -- a command line tool called **hub** could help you out.

Let's suppose that the project to which you submit the issue is called "test-repo". The issue is Issue #1. The issue may look something like this:

The Issue

You have forked this repo, and you have committed some modification in a branch "my-changes" and pushed them to your repo.

The Fork

Now let's convert this issue to a pull request.

First follow the installation instructions on hub project page to install hub.

Then clone your fork to your local directory if you have not done so. Say your local copy of the repo is at /home/user/test-repo. Switch your working directory to the git repo directory:

cd /home/user/test-repo

Then setup your GitHub token for this repo. After the setup,

use hub command to attach a pull-request to the issue you have submitted:

hub pull-request -i 1 -b ORIGINAL_AUTHOR:master -h YOUR_USER_NAME:my-changes

You will then be asked for your GitHub username and password. The number 1 in the above command means the number of the issue you created. In this example, it's Issue #1, thus 1 is passed to the -i option.

Now this issue should look like this:

The Issue

The pull request is now successfully attached to the issue.