Course material, available in Catalan, Spanish and English.

Teaching guide · Session 4 — Branches and pull requests

1. Goal and continuity

Learners arrive from S3 with existing code, context and history on GitHub. They now prepare a small change on a branch, show its diff, test it, review it with AI assistance and consciously integrate it into main. A branch separates commits; it creates neither another spreadsheet nor another deployment.

The session is self-paced. This guide supports a group workshop of around 150 minutes, or several shorter meetings. No specific AI tool is required: an external chat receives sanitised material; an agent acts only within its tools and permissions. The person still decides whether to merge.

2. Prepare the environment

3. Suggested schedule

Time Activity Evidence
0–15 min Resume S3, review repo, context and main state Identified starting point
15–35 min Define the change and create the branch in the working copy Branch name and goal
35–65 min Apply a small AI-assisted change Limited diff and reviewed files
65–90 min Test the copy at /dev: valid case, invalid case and access Expected and observed results
90–115 min Commit/push, open PR and review the latest commit Main base, compare branch, diff, tests and pending work
115–140 min Verify review findings and merge if ready PR Merged and commit on main
140–150 min Synchronise, record recovery and self-check Clean working copy and completed worksheet

Do not merge a defective change just to finish the route. Leave missing tests pending and explain the blocker. Course progress retains six steps and does not erase earlier notes.

4. Where to pause and explain

Situation Teaching response
Branch created on the web, Codespace still on main Explain fetch and switching to the local branch; check its name before editing
Modified files before switching branches Preserve them and decide where they belong; do not give blind reset or clean commands
Empty, oversized PR or unexpected files Check repo, base, compare and commits; reduce scope before continuing
AI says “all good” Ask for findings with file/line and a test; compare with the current diff
Cannot approve own PR Do not require formal self-approval. One participant documents review and tests; another person may review if available
Conflicts Stop merging and compare intent and contents with help; do not automatically accept every version
Merge does not change the app Separate repository and deployment. Publishing remains explicit in S4

For an accidental commit on main, distinguish local from shared history. Preserve work and ask for help with the specific state; creating a branch afterwards does not undo main. In shared history, prefer a reviewed revert to rewriting it with force push.

5. Prompts and review criteria

The page offers three canonical prompts: s4.build, s4.review and s4.pr, also in the localised bank. The first proposes a bounded change, the second reviews the specific diff and the third prepares a useful PR description. Complete them with context and actual results; do not copy errors, secrets or personal data without sanitising them.

A useful review explains the problem, its location and how to verify it. AI can be wrong or miss a defect: it replaces neither tests nor human approval. If code changes afterwards, review the latest diff and repeat affected tests.

6. Closing and assessment

Ask learners to explain their intended change, what the diff shows, what they tested, which commit was merged and what remains pending. Check that they can find the change on main and update their local copy without losing work.

Deleting the branch is not required. To recover an integrated change, propose and review a revert PR. Recovering code does not recover spreadsheet data.

The partner challenge is optional: minimum access to the practice repo, review by another person and removal of access when appropriate. Protection depends on the plan and effective rules; S5 covers it further. Do not make a repo public to enable a feature.

Materials

Reviewed on 2026-10-26. The HTML is generated from this Markdown; links target the website’s resources folder.

Page generated automatically from recursos/s0-s6/en/guia-professor-sessio4.md · reviewed on 2026-10-26. Edit the .md, not this file.
Download material as Markdown (.md)