Ravindra BagaleCourses & study guides

Chapter 3: Branching, Merge and GitHub PRs

3.5 GitHub pull requests — review before merge

A pull request (PR) is a proposal on GitHub: "Please take the commits from my branch into main (or another base)." Reviewers see the diff, comment, and approve or request changes. CI (later chapters) can run tests on the PR.

Why. Direct push to main skips review. A PR is the gate: eyes on the change, then merge.

Tiny story. You push feature/health. On GitHub you open a PR into main. A teammate asks for a README note. You push one more commit to the same branch — the PR updates. After approve, you merge. GitHub can delete the branch for you.

Steps — open and merge a PR (GitHub UI)

  1. Push your branch: git push -u origin feature/health (remote origin from clone or git remote add).
  2. Open the repo on GitHub — use Compare & pull request if shown.
  3. Set base = main, compare = feature/health.
  4. Write a short title and why the change exists (not just "update").
  5. Create the pull request.
  6. Wait for a review (classmate, trainer, or yourself on a practice repo).
  7. Merge with Create a merge commit or Squash and merge as the repo settings allow.
  8. Pull locally: git switch main then git pull.

What you see: green merged state on GitHub; local main matches after git pull.

Protect main

On GitHub: Settings → Branches → Branch protection for main. Require a pull request before merging. Even on a solo learning repo this trains the real habit. Companies block direct commits to main for a reason.

Ravindra Bagale's Tip

Interview madhe vichartaat: "PR madhe kay baghtat?" — Diff size, tests, secrets nahiye ka, README / migration notes, rollback idea. Fakt "code looks fine" nahi. Bilkul visru naka.

Lab

On GitHub (or local + GitHub):

  1. From main, create feature/health and add a health endpoint commit.
  2. Push the branch and open a pull request into main.
  3. Review the diff yourself — check no .env or keys.
  4. Merge the PR.
  5. On your laptop: git switch main && git pull and confirm the file is there.
  6. Delete the remote branch if GitHub did not already.