Lesson 2 of 6 · 14 min

Branches, Pull Requests & Code Review

Work the way real teams do, with branches, PRs and reviews.

The team workflow

On almost every team, nobody pushes directly to main. Instead:

  1. Create a branch for your change
  2. Commit your work there
  3. Push the branch and open a pull request (PR)
  4. A teammate reviews it, and you address feedback
  5. The PR is merged into main
git switch -c add-login-form     # create and switch to a branch
# ...edit, add, commit...
git push -u origin add-login-form

Then open the PR on GitHub.

Writing a good PR

## What
Adds client-side validation to the signup form.

## Why
Users were submitting empty emails (issue #42).

## How to test
1. Go to /signup
2. Submit with an empty email → you should see an error

Merge conflicts

Conflicts happen when two branches change the same lines. Git marks them:

<<<<<<< HEAD
const limit = 10;
=======
const limit = 20;
>>>>>>> add-pagination

Decide what the code should be, delete the markers, then commit. Don't panic: conflicts are routine.

Code review is a skill

Being reviewed teaches you fast. Reviewing others (and AI-generated code) is how you show seniority. Look for correctness first, then clarity, then style, and always be kind.

Portfolio tip: Open PRs on your own projects, even when you work alone. It shows employers you know the workflow.

✅ Check your understanding

  1. Why work on a branch instead of directly on main?

  2. You get a merge conflict. What's the right first step?

  3. What makes a pull request easy to review?

Create a free account to track your progress.