GitHub Pull Requests Step by Step: Create, Review, Update and Merge

Pull requests are how teams on GitHub propose, discuss, test and merge changes. In this lesson you will open your first pull request, write a description reviewers love, update it after feedback and merge it the right way.

Advertisement

📖 What You’ll Learn: what pull requests are, the full PR workflow, opening a PR and its fields, writing a good description, draft PRs, the PR tabs, updating a PR and handling an out-of-date branch, the three merge methods, PRs with the GitHub CLI, and best practices.


🔃 What Is a Pull Request?

A pull request (PR) is a request to merge the changes from one branch into another, usually from a feature branch into main. It is the heart of teamwork on GitHub:

  • Teammates review the code and discuss it line by line.
  • Automated checks (tests, linting, builds) run on the changes in GitHub Actions.
  • The change is merged only when it is approved and the checks pass.

Pull requests also create a permanent record of why a change was made.


🧭 The Pull Request Workflow

1. Create a branch      git switch -c feature/login-tests
2. Commit your changes  git commit -m "Add login tests for locked-out users"
3. Push the branch      git push -u origin feature/login-tests
4. Open a pull request  on GitHub (or gh pr create)
5. Review and checks    teammates comment, CI runs
6. Update if needed     more commits on the same branch update the PR
7. Merge                squash, merge commit or rebase
8. Clean up             delete the branch

Steps 1 to 3 are covered in Git Branches and clone, push and pull.


📝 Step 1: Open the Pull Request

After you push a branch, GitHub shows a yellow banner with Compare & pull request. Click it (or open Pull requests, New pull request and choose the branches).

FieldWhat to fill in
baseThe branch you want to merge into (usually main)
compareYour feature branch
TitleA short summary, e.g. “Add login tests for locked-out users”
DescriptionWhat changed, why, how it was tested, screenshots, and linked issues
ReviewersTeammates who should review
AssigneesWho is responsible for the PR (usually you)
Labelse.g. tests, bug, enhancement

A good PR description

## What
Adds login tests for locked-out and invalid users.

## Why
Locked-out users were not covered; see the bug in #42.

## How it was tested
- Ran npx playwright test tests/login.spec.ts in Chromium and Firefox
- All 6 tests pass locally and in CI

Closes #42

Writing Closes #42 (or Fixes or Resolves) links the PR to issue 42 and closes the issue automatically when the PR is merged into the default branch. See Issues and Projects. Teams often provide this structure with a pull request template.


✍️ Draft Pull Requests

Not ready for review but want feedback or CI results? Choose Create draft pull request from the dropdown on the green button. When finished, click Ready for review.


🔍 Step 2: The PR Page

TabShows
ConversationDescription, comments, review summary, checks and the merge box
CommitsEvery commit on the branch
ChecksResults of GitHub Actions and other CI
Files changedThe diff, where reviewers comment line by line (code review)

🔁 Step 3: Update the PR After Feedback

Just commit and push to the same branch; the PR updates automatically:

# fix the review comments, then:
git add tests/login.spec.ts
git commit -m "Use getByRole for the login button"
git push

If main moved on and the PR shows “This branch is out-of-date with the base branch”, click Update branch on GitHub, or locally:

git fetch
git rebase origin/main          # or: git merge origin/main
git push --force-with-lease     # needed after a rebase

Conflicts? GitHub can resolve simple ones in the browser with Resolve conflicts; otherwise resolve them locally (merge conflicts).


✅ Step 4: Merge the Pull Request

The merge box offers up to three methods (repository admins choose which are allowed):

ButtonWhat happensHistory on main
Create a merge commitAll branch commits plus a merge commitComplete, shows the branch
Squash and mergeAll branch commits combined into one commitOne clean commit per PR
Rebase and mergeBranch commits replayed on top of main, no merge commitLinear, keeps every commit

Many teams use Squash and merge so each PR becomes one readable commit on main. Background: git merge and git rebase.

After merging, click Delete branch, then clean up locally:

git switch main
git pull
git branch -d feature/login-tests
git fetch --prune

⌨️ Pull Requests from the Terminal

With the GitHub CLI:

gh pr create --title "Add login tests" --body "Closes #42" --reviewer teammate
gh pr list
gh pr checkout 57          # check out someone else's PR locally to test it
gh pr merge 57 --squash --delete-branch

💡 Tip: As a tester, gh pr checkout <number> is the fastest way to run a developer’s branch locally and test it before it is merged.


✅ Pull Request Best Practices

  • Small PRs: under about 400 changed lines are reviewed faster and better.
  • One purpose per PR: do not mix a bug fix, a refactor and a new feature.
  • Clear title and description, with testing notes and screenshots for UI changes.
  • Green checks before asking for review.
  • Respond to every comment, then mark conversations resolved.
  • Protect main so changes can only arrive through reviewed PRs (branch protection).

📝 Assignment

  1. In your git-practice repository on GitHub, create a branch, commit a change, push it and open a pull request with a good description.
  2. Open a second PR as a draft, then mark it ready for review.
  3. Add a new commit to the first PR and watch it update.
  4. Create an issue, then open a PR with Closes #<number> and merge it with Squash and merge; confirm the issue closed.
  5. Make main move ahead, then update an open PR’s branch with Update branch or a local rebase.
  6. Bonus: install the GitHub CLI and create and merge a PR with gh pr create and gh pr merge.

❓ FAQ

🤔 What is a pull request in GitHub?

A request to merge changes from one branch into another, with a place for discussion, code review and automated checks before the merge.

🤔 How do I create a pull request?

Push your branch, click Compare & pull request on GitHub (or Pull requests, New pull request), choose base and compare branches, add a title and description, and click Create pull request.

🤔 What is the difference between squash and merge and rebase and merge?

Squash and merge combines all PR commits into one commit on the base branch. Rebase and merge replays each commit on top of the base branch without a merge commit.

🤔 How do I update a pull request?

Push new commits to the same branch. The PR updates automatically.

🤔 How do I link a pull request to an issue?

Write Closes #<issue-number> in the PR description; the issue closes when the PR is merged into the default branch.


🎯 Next Steps

🎬 Learn Git and GitHub step by step: watch the series on YouTube!

Subscribe to SqaToolsByDY • Practice on sqatools.in

5 thoughts on “GitHub Pull Requests Step by Step: Create, Review, Update and Merge”

Leave a Comment