Bootcamp
Search
K

0.3.1: Pull Requests

Learning Objectives

  1. 1.
    Pull requests are requests to merge, aka "pull" changes from 1 branch to another. They are typically used for code review before merging feature branches to the main branch.
  2. 2.
    Know how to create pull requests in GitHub
  3. 3.
    Know how to leave comments on and merge pull requests in GitHub

Introduction

A GitHub pull request (PR) is a request to merge or "pull" changes from 1 branch on GitHub to another. PRs are most commonly used for code review, where SWEs share PRs for peer review before merging that code to a main branch. Reviewers can comment on individual lines in the PR and request changes before the code is merged. Rocket uses PRs for student code submission and review.
A pull request on Facebook's React repo
Reviewers can leave comments on pull requests to acknowledge good work and request changes

How to create, comment on and merge pull requests

Below is a demo video for how to create, comment on and merge pull requests.
Demo video on how to create, comment on and merge pull requests
To create a pull request to merge a change from a feature branch to main (or any other branch), first push the latest changes from that feature branch from our local repo to GitHub.
Once the latest changes on that feature branch are in GitHub, we can navigate to the "Pull requests" tab in our repo's GitHub page and click "New pull request".
Navigate to Pull requests tab and click New pull request to initiate new PR
Verify we are merging the correct source and target branch, and correct commits and code changes. Once verified, click "Create pull request".
Verify we have the correct branches and commits before creating pull request
Leave a descriptive title and description for reviewers, then click "Create pull request".
Leave descriptive title and description for each PR
If you are a reviewer or want to leave comments for your reviewer, hover over the relevant line of code and click the "+" icon to leave a comment on that line. To comment on multiple lines, click and drag the "+" icon over the relevant lines.
Click "+" icon to comment on 1 or more lines in the PR
Once reviewers have approved the PR, click "Merge pull request" in the PR's Conversation tab to merge the relevant branches and close the PR.
Once reviewers have approved, merge the PR to merge relevant branches and close the PR
After merging the PR, we should see the merged code in the target branch, in this case main.
Merged PRs have a "Merged" status
After merging, target branch should contain the latest changes