Skip to main content

GitKit (Linux Desktop Edition): Learn git and GitHub in Context

Section 3.8 Creating a Pull Request

A pull request is the mechanism by which you ask the maintainers of a project to consider merging your changes into the upstream main branch.

Exercises

As shown in Figure 3.8.1, a pull request is made from your origin repository, which must contain your feature branch, to the upstream repository. In the last section, you pushed your feature branch to your origin repository, so you are now ready to make a pull request.
Cloud image of the state of the repository when making a pull request.
Figure 3.8.1. Making a Pull Request.

1.

There are a number of different ways to make a pull request in GitHub. In general, they are all equivalent and it won’t matter which one you use. The following steps will walk you through one of those ways.
(a)
When you first push a feature branch GitHub assumes that you are likely to make a pull request for it. To make this easy it will automatically display a big green “Compare & pull request” button at the top of the page for your origin repository.
GitHub compare and pull request button image.
Click that button. You will use the page that appears to create your pull request.
(b)
A gray bar similar to the one shown below should appear at the top of the page.
Image of the GitHub bar showing the repository and branch for the pull request.
This bar specifies the repositories and branches that are involved in the pull request. That is, they indicate which branch you are requesting to be pulled from which repository and to which branch in which repository you would like it to be merged.
Note that the specific information that you see in your browser will be different than what is shown above.
The questions in this exercise will help you to better understand what this information means.
(i)
Copy the URLs from the gray bar into the textboxes below.
(A)
Base Repository
(B)
Head Repository
(ii)
Hint.
The base is where you want your changes merged into/the repository you created your fork from. The head is where your changes are being pulled from/the branch you pushed to your GitHub account from your local machine.
(iii)
Hint.
The base is where you want your changes merged into. The head is where your changes are being pulled from.

2.

(a)
Give your PR a descriptive title - a similar idea to using meaningful commit messages.
(b)
Replace the <add description> in the body of the PR with a longer description of your changes.
(c)
If a PR fixes an issue, which yours does, then you should include a line in the body of the PR that says exactly: Fixes #123 or exactly: Closes #123.
When a PR with one of these lines is merged into the project the listed ticket from the issue tracker (e.g. 123 in this example) will be closed automatically. Including these lines is very helpful to the project maintainers because then they do not have to remember to go close the associated ticket each time they merge a pull request.
Add a line to the body of the PR that will close the issue that you fixed.
The #123 part of the line should automatically become a link to the ticket. If it does not, check to be sure you have entered the information exactly as shown above.
(d)
Check that status of your PR and confirm that it can be merged automatically. The status will be listed at the top of the GitHub page below the image from Task 3.8.1.b
(e)
Click the green button to create the Pull Request.
GitHub create pull request button image.

3.

Go to the upstream repository on GitHub and open the “Pull Requests” tab:
GitHub pull requests tab image.
Find your Pull Request and give a link to it here.

4.

On your pull request page there will be “Files Changed” tab:
GitHub pull requests tab image.
Open that tab. At the bottom of that page will be a diff that shows the changes that you have made. This diff shows both the upstream version of the code and your version of the code. It also indicates the changes you have made. The project maintainers will often use this diff to see the details of what you have changed.
(a)
    Briefly describe how the diff indicates the changes that you made.
  • The line(s) which contains the change(s) appears twice. Once in red with the old version and once in green with the new version. The change(s) appear in both in bold.
  • The line(s) which contains the change(s) appears once in red.
  • The line(s) which contains the change(s) appears once in green.
  • Only the changed word(s) appear with the old in strike through and the new next to it.
You have attempted of activities on this page.