Objective: practice fork-based collaboration, PR hygiene, and recovery tools. Produce a lab log (codes/lab04/lab-notebook.md) with commands, short explanations, and screenshots where useful. Use a fork or a bare “upstream” plus a working clone under codes/lab04/.
Exercise 1 — Fork, remotes, and PR prep¶
Fork the course repository (or create a local bare repo as
upstream.git) and clone your fork as the working copy.Add remotes:
origin(your fork) andupstream(canonical). Showgit remote -vandgit remote show upstream.Create
feature/review-checklistfromupstream/main, commit 2–3 focused changes (e.g., add a PR checklist doc + small script). Use meaningful messages.Rebase onto latest
upstream/main, resolve any conflicts, and push the branch to your fork (git push -u origin feature/review-checklist). Capturegit log --graph --oneline --decorate --all.
Exercise 2 — Clean history and review cycle¶
Run
git rebase -i upstream/mainto squash/fixup noisy commits; document the before/aftergit log --oneline.Open a pull request (or simulate locally) and write a PR description with problem, approach, and tests. Note any CI/pre-push hooks run.
Receive simulated review feedback: make a follow-up commit addressing comments, then squash if your project prefers a tidy history.
Practice safe force-push:
git push --force-with-lease. Explain why--force-with-leaseis safer than--force.
Exercise 3 — Conflict handling and recovery tools¶
Enable rerere (
git config --global rerere.enabled true), manufacture a merge or rebase conflict, resolve it, and show rerere auto-applying on a second run.Demonstrate
git worktree add ../wt-hotfix hotfix/criticalto work on two branches without stashing. Merge the hotfix back cleanly.Run a mini
git bisecton a provided script with a known regression; log commands and the identified bad commit.Use
git reflogto recover a deliberately “lost” commit (e.g., after a reset) and restore it viagit cherry-pick. Include the reflog entries used.
Submission checklist¶
Lab notebook with commands, explanations, and conflict/resolution notes.
Repository archive (
lab04.bundleor.zip) including branchfeature/review-checklistand tagv0.1-collab(if applicable).PR link or simulated PR description; mention open questions or tricky points for Lecture 5 discussion.