← Learning Hub
Intermediate

Pull Requests and Code Review

In a team, nobody pushes straight to main. You push a branch and open a pull request (PR): a request to merge it, where teammates review the code first.

A pull request is a proposal: "here are my changes, please review and merge them". Teammates comment, automated checks run, and only approved changes reach the main branch. It's how code quality is maintained in professional teams and open source.

The everyday flow

Example
git switch main
git pull                                  # start from the latest main
git switch -c fix-cart-total              # one branch per task
# ... edit, test ...
git add .
git commit -m "Fix cart total when coupon is removed"
git push -u origin fix-cart-total
  • On GitHub, click Compare & pull request.
  • Write what the change does, why, and how you tested it. Add screenshots for UI changes.
  • Reviewers comment on lines; automatic checks (tests, builds) run.
  • Push more commits to the same branch to answer comments - the PR updates by itself.
  • When approved and checks pass, click Merge, then delete the branch.

Being a good reviewer

  • Check that it does what the PR says, and look for bugs and missing edge cases.
  • Be kind and specific: "This breaks when the cart is empty - maybe check items.length first?"
  • Approve small, clear PRs quickly. Big PRs are hard to review - ask to split them.

Forks: contributing to someone else's project

On a project you can't push to, click Fork to make your own copy, push your branch there, and open a PR back to the original.

Branch protection rules on GitHub (Settings → Branches) can require reviews and passing checks before anything merges into main.
Key points
  • A PR proposes merging a branch into main.
  • Reviews and checks happen before merging.
  • Keep PRs small and well described.

📝 Test yourself

1. What is a pull request?
2. How do you update an open PR after review comments?
3. Fill in what you click to copy someone else's repository to your account: