Track 05 · Lesson 5 of 7Working as a team with Git

Track 05 · Working as a team with Git

After the PR is open

Lesson 5 of 7· 8 min

Opening the PR is half the job. Then come the checks, the out-of-date warnings, the review comments and finally the merge. Each one has a short, calm routine.

Pick a merge button

Compare what each one leaves in history

$ git log --oneline --graph develop* 8d7c6b5 feat: add login page (#123)* 9f0e1d2 feat: add profile page (#118)* 2c1d0e9 chore: set up CI
Commits added
1
History
Straight line
Undo it
One revert

The whole PR becomes one tidy commit. Most teams pick this. The PR page keeps the details.

Same thing without the prompts: gh pr merge 123 --squash --delete-branch

Same branch, same PR#

Every fix after review goes onto the same branch. git push updates the PR in place, keeps the conversation, and re-runs the checks. Opening a new PR for fixes loses all of that.

When the PR is finally green and approved, the merge method decides what lands in the shared history. Squash is the common default: one commit per PR, easy to read and easy to undo. Follow your team's rule if it has one.

CI failed on my PR#

When: Your PR shows a red X, or someone says "your build is failing".

$ gh pr checks
1/8

Shows every automatic check on your PR.

Commands to copy

  • $ gh pr checks

    Which checks failed?

  • $ gh run view 987654321 --log-failed

    Only the error logs

  • $ gh pr checks --watch

    Wait for the new run after you push

  • $ gh run rerun 987654321 --failed

    Flaky test? Re-run only the failed jobs

My PR is out of date with the target#

When: GitHub says "This branch is out-of-date with the base branch", or teammates merged things into develop that you need.

$ gh pr update-branch 123
1/10

GitHub merges the latest develop into your branch for you. This works when there are no conflicts.

Commands to copy

  • $ gh pr update-branch 123

    Easy way (no conflicts)

  • $ git fetch origin

    Conflict way, step 1

  • $ git merge origin/develop

    Step 2: conflicts show up here, so fix them in VS Code

  • $ git add . && git commit && git push

    Step 3: save and send

A reviewer asked for changes#

When: Your PR shows "Changes requested".

$ gh pr view 123 --comments
1/6

Read all the review comments right in the terminal.

Commands to copy

  • $ gh pr view 123 --comments

    Read the feedback

  • $ gh pr comment 123 --body "Addressed all comments, ready for another look."

    Reply after pushing fixes

  • $ gh pr view 123 --web

    Reply to specific line comments on GitHub

Merge my PR#

When: Your PR is approved and all checks are green. Check your team's rules first, because sometimes only leads merge.

$ gh pr merge 123
1/5

Type this and press Enter.

Commands to copy

  • $ gh pr merge 123 --squash --delete-branch

    Same thing, no questions

  • $ gh pr merge 123 --auto --squash

    Checks still running? Merge automatically when they pass (if the repo allows it)

Check yourself

A reviewer asked for changes. What's the right way to send your fixes?