Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Version Control with Git  ›  Capstone Project

Pull Requests and Code Review

GitLab 14 minA pull request on GitHub, or merge request on GitLab, proposes merging a branch into main so teammates can review it and automated checks can run before it is merged.

Pull Requests and Code Review

Your friend has finished the new menu layout on a branch. Should they just merge it into main themselves? On a real team, almost never. Someone else reads the change first, automated checks run, and only then does it go in. On GitHub this is a pull request; on GitLab the same idea is called a merge request.

The rule

Propose on a branch, discuss, check, then merge into main.

The flow looks the same on both services:

  1. Branch and commit. Work on a branch such as new-menu-layout, never directly on main.
  2. Push the branch. git push -u origin new-menu-layout puts it on the remote.
  3. Open the request. On the website, ask to merge new-menu-layout into main. Give it a clear title and a description: what changed, why, and how to check it (for example, "Open the menu page on a phone; cards should stack in one column").
  4. Review. Teammates read the changes line by line, leave comments, ask questions and suggest improvements. Reviewers either approve or request changes.
  5. Checks. Automated jobs can run on every request, such as tests, a linter or a preview build of the site. A red check blocks the merge until it is fixed.
  6. Update. To answer feedback, commit more fixes to the same branch and push. The request updates itself; there is no need to open a new one.
  7. Merge. Once approved and green, someone merges. The branch can then be deleted.

Teams often protect main so that changes cannot be pushed to it directly. Every change must come through a reviewed request.

Small is kind. A request that changes 40 lines gets a careful review within an hour. One that changes 2,000 lines gets skimmed or ignored for a week. Split big work into a series of small, focused requests.

Reviewing well means commenting on the code, not the person: "This selector also matches the footer links; could we scope it to .menu?" rather than "This is wrong." Point out the good parts too.

The shortcut

Before opening a request, write its description as if the reviewer knows nothing: What changed? Why? How do I see it working? If you cannot answer the three in a few lines, the request is probably too big or not ready.

Shipping the new menu layoutStep 1 of 4
  1. Push the branch

    git push -u origin new-menu-layout puts the branch on the remote.

Drills

Answer fast — trust the rule.

quick drill

What does GitLab call its version of a pull request?

quick drill

A reviewer asks for a change. How do you update the open pull request?

quick drill

Why do teams protect the main branch?

quick drill

Which pull request is most likely to get a careful, quick review?

Remember

  • Propose on a branch, discuss, check, then merge into main.
  • Describe it for a reviewer who knows nothing: what, why, how to see it.
  • Trap: huge requests get skimmed; small ones get real reviews.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainFrom branch to main

Explain the full flow for getting the new menu layout from your laptop into main on a team that protects main. Include what goes in the request's description and how you respond to review comments.