Episode 4 of 7GitHub for Beginners

Pull requests

The video only loads when you click the picture. Until then your browser does not connect to YouTube.

Stop for a moment before you merge

You have a branch with changes. You could merge it into main straight away. But on a team, and even on your own, it's worth stopping for a moment first.

A pull request is a request

With a pull request you're saying: “I made changes on this branch. Take a look, and if they're good, put them into main.”

The name is a bit confusing. You're asking whoever looks after the project to pull your changes in. GitLab, a competing site, calls the same thing a merge request, which is clearer.

What a pull request shows

A pull request shows exactly what will change: every file, every line, in red and green. Like a commit, but for the whole branch at once.

The review

Whoever checks it can comment on one specific line: “Something's missing here.” “This could be simpler.” That check is called a review.

You fix things based on the comments and make another commit on the same branch. It joins the pull request by itself, so there's no need to open a new one.

Merge, and the conversation stays

When everyone's happy, you merge. The branch goes into main and the pull request closes. The whole conversation is kept, so a year from now you can still see why the change was made.

Open a pull request

  1. After you commit to a branch, GitHub usually shows a yellow bar at the top with a Compare & pull request button. Click it.
  2. No yellow bar? Open the Pull requests tab, click New pull request, pick your branch and compare it with main.
The “Comparing changes” page: base main, compare new-homepage, and the green “Create pull request” button.12
  1. compare: is your branch, base: is main.
  2. Click Create pull request.
  1. Give the pull request a title and a few lines: what you changed and why. Then click Create pull request.
The pull request form with the title “New homepage”, a short description, and the green “Create pull request” button.12
  1. A short title.
  2. Click Create pull request.

Comment on a line

Open the Files changed tab. This is what the reviewer sees. Hover over a line, click the plus that appears next to it, and leave a comment.

Merge it

  1. Go back to the first tab, Conversation, and click Merge pull request.
  2. Then click Confirm merge. It appears in the same place.
The merge box of a pull request: “No conflicts with base branch” and the green “Merge pull request” button.1
  1. Merge pull request, then Confirm merge.

GitHub then offers to delete the branch. It has done its job.

After the merge: “Pull request successfully merged and closed” with a “Delete branch” button.1
  1. Delete branch: the branch is merged, you can let it go.

Go back to the repo page. Your change is now on main.