GitHub & Collaboration
Chapter 28 covered local git — commits, branches, merging, rebase, resolving conflicts, undoing changes. All of that happens on your own machine, in a repository nobody else can see. This chapter is about the layer on top: sharing that history with other people. GitHub doesn't replace git — it's a hosted copy of your repository, plus a set of tools (pull requests, reviews, issues) built around the act of moving commits between machines and getting other humans to look at them before they land.
How to read this chapter
- Sub-topic 1 covers remotes — what
originactually is, and the real difference betweenfetchandpull, verified against a real second repository standing in for GitHub. - Sub-topic 2 covers forking vs. cloning — when each is the right call, and how to keep a fork in sync with the project it came from.
- Sub-topic 3 covers the actual pull request workflow, start to merge, plus draft PRs.
- Sub-topic 4 covers code review — what a reviewer is actually checking for, and how to give and receive feedback without it turning into a fight.
- Sub-topic 5 covers issues — writing one that's actually useful, and how labels/milestones/PR-linking keep a project's work visible.
- Sub-topic 6 ties every sub-topic together into one realistic scenario, from a filed issue to a merged PR.
- A note on the commands in this chapter: every
git remote/push/pull/fetchexample was run for real against a local bare repository (git init --bare) standing in for a GitHub remote — the output shown is actual terminal output, not invented. GitHub's own web UI (pull request pages, the issue tracker, the review interface) can't be screenshotted in a text-only build environment, so those are shown as clearly-labeled text mockups instead — described in prose, not presented as real screenshots.
1. Remotes
- A remote is just another copy of the repository that your local git knows how to talk to — usually hosted on GitHub, but it can be anywhere reachable over a URL or filesystem path.
originis a name, not a keyword — it's the conventional label git gives the remote you cloned from, and nothing stops you from renaming or adding more.fetchdownloads a remote's history without touching your working branch;pulldoes afetchand then immediately merges it into the branch you're on.
git remote add <name> <url> is the one command that tells it "there's another copy of this repo over there, and I want to call it <name>."
GitHub itself is nothing more than a hosting service for bare git repositories, plus a web UI built on top. To prove that honestly — not just assert it — every example below runs against a real second repository on this machine, created with git init --bare, which behaves exactly like a GitHub remote would: it has no working directory, only the raw commit history, and it only accepts pushes and serves fetches.
# stand in for "a repo on GitHub" -- a real bare repo, verified end to end
git init --bare upstream-remote.git
# a normal, local project
git init recipe-box
cd recipe-box
git checkout -b main
echo "# Recipe Box" > README.md
git add README.md
git commit -m "Initial commit"
# connect the local repo to the "remote"
git remote add origin ../upstream-remote.git
git remote -v
origin ../upstream-remote.git (fetch)
origin ../upstream-remote.git (push)
Two lines for one remote — git tracks fetch and push as
separate URLs for the same name, since some setups genuinely do
point them at different places (rare, but the split exists on
purpose). -u on the first push does one more thing
worth calling out: it sets up a tracking branch,
linking local main to origin/main so
later git push/git pull calls don't need
the remote and branch spelled out every time.
git push -u origin main
To ../upstream-remote.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
Thought process: before touching GitHub at all, the goal is proving what a remote actually is with a setup nobody has to take on faith -- a real bare repo, not a screenshot of github.com. git init --bare is the right stand-in because it's genuinely the same shape as what GitHub hosts: no working directory, just the raw object history, reachable only by push/fetch.
Write the prompt you'd give an AI assistant to build this:
Show a strong version of this prompt
Using only git commands in a terminal, create a bare repository called upstream-remote.git with `git init --bare` to act as a stand-in for a GitHub remote. Then create a separate normal git repository called recipe-box, add a README.md, commit it on a branch named main, connect it to the bare repo with `git remote add origin ../upstream-remote.git`, and push it with `git push -u origin main` so the branch is set up to track origin/main. Show the output of `git remote -v` and the push command.
With the remote connected, here's the actual difference between
fetch and pull — the single most
common source of confusion for anyone new to remotes. Someone else
pushes a change; verify what each command does, one at a time:
# (a teammate's clone pushed a new commit to origin/main in the meantime)
git fetch origin
From ../upstream-remote
73532d6..056af9b main -> origin/main
Notice what didn't happen: the local main
branch and the working directory are completely untouched.
fetch only updates git's local record of where
origin/main points — it downloads the new
commit into the repository's object database and moves the
remote-tracking pointer, nothing more. This is confirmed directly:
git log --oneline # local main -- unchanged
git log --oneline origin/main # what fetch downloaded -- one commit ahead
73532d6 Add feature X
b60638f Initial commit
056af9b Teammate pushes a change
73532d6 Add feature X
b60638f Initial commit
pull is the command that actually changes your
working branch — it's fetch immediately followed
by a merge (or rebase, with the right flag) of the fetched commits
into the branch you're on:
git pull origin main
From ../upstream-remote
* branch main -> FETCH_HEAD
056af9b..89ad16c main -> origin/main
Updating 056af9b..89ad16c
Fast-forward
app.py | 1 +
1 file changed, 1 insertion(+)
This one was a fast-forward — the local
branch had no commits of its own beyond what the remote already
had, so git just slides the branch pointer forward, no merge
commit needed. Chapter 28 already covered what happens when both
sides have diverging commits instead (a real merge or conflict) —
the exact same rules apply here, pull is just
fetch plus that same merge machinery, aimed at a
remote instead of another local branch.
git fetch origin
-> downloads new commits, updates origin/main
-> your current branch: UNCHANGED
git pull origin main
-> downloads new commits (= fetch)
-> THEN merges them into your current branch
-> your current branch: UPDATED
git push -u origin main (or git branch --set-upstream-to) sets this up once; afterward, plain git push and git pull with no arguments know to talk to origin/main automatically. git status also uses it to report things like "Your branch is 2 commits behind origin/main."
- A remote is a named URL/path git knows to talk to;
originis just the conventional name for the one you cloned from. git fetchdownloads new commits and updates remote-tracking branches (likeorigin/main) without touching your current branch.git pullisfetchplus an immediate merge into the branch you're on — the command that actually changes your working files.
Go Deeper: why would you ever fetch without pulling?
Fetching first, then looking at what changed (git log
origin/main, or git diff main origin/main)
before deciding whether to merge is a genuinely safer habit on a
shared branch — it lets you review incoming changes before
they touch your working directory, rather than merging blind.
Many experienced developers fetch by default and only pull (or
run git merge origin/main manually) once they've
actually looked.
- A remote is another copy of the repository git knows how to reach;
originis a name, not a special keyword. git remote add <name> <url>connects a repo;git push -usets up a tracking branch on first push.fetchdownloads without touching your branch;pulldownloads and merges in one step.
2. Forking vs. cloning
- Cloning copies a repository to your machine; it says nothing about permissions — you clone any repo you can already read.
- A fork is a full copy of someone else's GitHub repository, made under your own account, that you have full write access to.
- Fork when you don't have (and won't get) push access to the original; clone directly when you already do — your own projects, or a team repo you're a collaborator on.
git clone your fork down to your own machine, exactly like cloning any other repository.
The practical difference shows up the moment you try to push.
Cloning a repository you don't have write access to still lets you
commit locally — git doesn't stop you — but
git push against the original will fail with a
permissions error, because GitHub (not git) is enforcing who can
write to that specific remote. A fork sidesteps this entirely: it's
a full copy under your own account, so you can push to it freely,
then propose your changes back to the original via a pull request
(Sub-topic 3).
GitHub's actual repo page renders this as a styled button with a live fork count; this is a plain-text description of what it does, not the real UI.
github.com/octocat/some-project
[ Fork ] 1.2k [ Star ] 8.4k [ Watch ] 340
Clicking "Fork" creates a full copy of this repository
under YOUR account:
github.com/octocat/some-project (original -- "upstream")
|
| Fork button (on GitHub, not a git command)
v
github.com/your-username/some-project (your fork -- you own this)
You still need `git clone` to get YOUR fork onto your
own machine -- forking alone only creates the copy on GitHub.
Once your fork exists (on GitHub) and you've cloned it (onto your
machine), your local origin points at your
fork by default — not the original project. To stay current
with the original as it keeps moving, add it as a second remote,
conventionally named upstream:
# after: fork on GitHub, then `git clone` your fork locally
git remote -v
origin /path/to/my-fork-remote.git (fetch)
origin /path/to/my-fork-remote.git (push)
git remote add upstream /path/to/upstream-remote.git
git remote -v
origin /path/to/my-fork-remote.git (fetch)
origin /path/to/my-fork-remote.git (push)
upstream /path/to/upstream-remote.git (fetch)
upstream /path/to/upstream-remote.git (push)
Syncing a fork is now a normal fetch-and-merge, just aimed at
upstream instead of origin, followed by a
push back to your own fork so GitHub shows it up to date too:
git fetch upstream
git merge upstream/main -m "Merge upstream/main into fork"
git push origin main
From /path/to/upstream-remote
* [new branch] main -> upstream/main
Updating 89ad16c..e264451
Fast-forward (no commit created; -m option ignored)
app.py | 1 +
1 file changed, 1 insertion(+)
To /path/to/my-fork-remote.git
89ad16c..e264451 main -> main
Because the merge was a clean fast-forward, git ignored the
-m message entirely (there's nothing to attach it to
— no new commit was created, the branch pointer just moved).
If your fork had its own commits that diverged from upstream
instead, this would behave exactly like any other diverging merge
from Chapter 28: a real merge commit, or a conflict to resolve by
hand.
Thought process: keeping a fork in sync is really just "fetch from a remote you don't normally push to, then push the result to the one you do" -- naming the second remote `upstream` is convention, not a requirement, but it's the convention every real project assumes, so it's worth using even in a toy example.
Write the prompt you'd give an AI assistant to build this:
Show a strong version of this prompt
I have a local clone of my GitHub fork, where `origin` already points at my fork. The original project I forked from is at a different URL. Show me the exact git commands to: (1) add the original project as a second remote named `upstream`, (2) fetch its latest changes without touching my working branch, (3) merge upstream's main branch into my local main, and (4) push the result back to my fork (origin) so GitHub shows my fork up to date. Explain what happens differently if the merge is a clean fast-forward versus if my fork has its own commits that diverged from upstream.
- Cloning copies a repo you can already read; it doesn't grant new permissions.
- A fork is a full copy made under your own GitHub account, created on GitHub itself, that you fully control.
- Keeping a fork in sync means adding the original as an
upstreamremote, then fetch + merge (or rebase) from it, then push to your fork (origin).
Go Deeper: is a fork a full copy of the entire history?
Yes — a fork starts as a complete copy of the repository,
including every commit, branch, and tag that existed at the
moment you forked it. It's not a shallow snapshot. What it does
not automatically do is stay updated — a fork is
frozen at the moment you created it until you deliberately sync
it with upstream, which is exactly why forks can
drift out of date if you don't sync regularly.
- Clone when you already have (or will get) write access; fork when you don't and won't.
- A fork is created on GitHub, under your account, with full history — then cloned locally like any repo.
- Sync a fork by adding the original as
upstream, fetching and merging from it, then pushing the result to your fork (origin).
3. Pull requests
- A pull request (PR) is a GitHub-hosted request to merge one branch into another — it's not a git object at all, it's a GitHub feature layered on top of git branches you've already pushed.
- The workflow: branch, commit, push the branch, open a PR on GitHub, get it reviewed, address feedback, merge.
- A draft PR is the same thing marked "not ready yet" — visible for early feedback, but blocked from merging until marked ready.
main). It's created and lives entirely on GitHub — opening one doesn't touch your local repository at all, it just tells GitHub "here's a branch I've pushed; please compare it against the target branch and let people review the difference before it's merged."
Everything up through "push the branch" is exactly what Chapter 28 already taught, aimed at a remote instead of staying purely local:
git checkout -b add-shopping-list
# ... make changes, commit as usual (Chapter 28) ...
git push -u origin add-shopping-list
To ../upstream-remote.git
* [new branch] add-shopping-list -> add-shopping-list
branch 'add-shopping-list' set up to track 'origin/add-shopping-list'.
That push is the last purely-local step. From here, opening the actual pull request happens on github.com — GitHub detects the freshly-pushed branch and offers a "Compare & pull request" button. Since that page can't be honestly screenshotted in this environment, here's what it looks like, described as a plain-text mockup:
This represents GitHub's actual "Open a pull request" form, described in prose/structure since it can't be captured as a real screenshot here.
base: main <- compare: add-shopping-list
Title: Add shopping list feature
Description (markdown, supports checklists and issue links):
+----------------------------------------------------------+
| ## What this does |
| Adds a `ShoppingList` class with add/remove/total methods.|
| |
| ## Why |
| Closes #42 |
| |
| ## How to test |
| Run `python3 shopping_list.py` and try adding 3 items. |
| |
| - [x] Added tests |
| - [ ] Updated README |
+----------------------------------------------------------+
Reviewers: [ + Request review ] Labels: [ enhancement ]
[ Create pull request ] [ Create draft pull request ]
A good PR description does three things, and the mockup above is deliberately structured around them:
- What changed — a plain summary, not just a list of filenames.
- Why — the motivation, often linking a specific issue (
Closes #42is a real GitHub convention: merging this PR automatically closes issue #42, covered in Sub-topic 5). - How to verify it — exact steps a reviewer can run themselves, not "trust me, it works."
Thought process: a PR description is written for a reviewer who has zero context on what you were thinking -- the goal isn't to describe every line changed (the diff already shows that), it's to answer "why does this exist" and "how do I check it actually works" without them having to ask.
Write the prompt you'd give an AI assistant to help with this PR:
Show a strong version of this prompt
Write a GitHub pull request description in markdown for a branch called add-shopping-list being merged into main. It adds a ShoppingList class with add/remove/total methods, and it should close issue #42. Structure it with three sections: "## What this does" (plain summary, not a diff recap), "## Why" (motivation, with "Closes #42" so GitHub auto-links and closes the issue on merge), and "## How to test" (exact runnable steps a reviewer can follow, e.g. "Run python3 shopping_list.py and try adding 3 items"). Add a markdown checklist at the end with "Added tests" checked and "Updated README" unchecked.
After a PR is open, the workflow loops between review and revision, entirely by pushing more commits to the same branch — a PR isn't a snapshot, it's a live view of whatever the branch currently contains:
open PR --> reviewer comments --> you push new commits
^ |
| v
+--------- PR updates automatically <----+
(same branch, no new PR needed)
... repeat until approved ... --> merge --> branch usually deleted
- A PR proposes merging your pushed branch into another branch — it lives on GitHub, not in git's own history until merged.
- A strong description covers what changed, why, and how to verify it — not just a restated diff.
- Addressing feedback means pushing more commits to the same branch; the same PR updates automatically, no need to open a new one.
Go Deeper: does a pull request require a fork?
No — PRs work the same way whether the branch lives on a
fork or directly on the same repository. Team members with
direct push access typically branch straight on the shared repo
(git checkout -b feature-x, push, open PR);
outside contributors without push access fork first, since
that's the only way they get somewhere to push a branch to at
all. The PR mechanism itself doesn't care which situation
you're in.
- Branch, commit, push the branch, then open the PR on GitHub — opening a PR is a GitHub action, not a git command.
- A good description states what changed, why, and how to verify it, often linking an issue with "Closes #N."
- A draft PR is visible for early feedback but blocked from merging; pushing more commits updates the same PR in place.
4. Code review
- A reviewer is checking for correctness, readability, test coverage, and whether the change fits the project's existing conventions — not just "does it run."
- GitHub's three review outcomes are Comment (feedback, no verdict), Approve (good to merge), and Request changes (blocks merging until addressed).
- Feedback should target the code, phrased as a question or suggestion where possible — and receiving it well means treating it as information about the code, not a judgment of the person.
What an experienced reviewer is actually scanning for, roughly in the order they'd notice it:
- Correctness — does this actually do what the PR description claims, including edge cases the happy-path tests might miss?
- Tests — is the new behavior covered, and do the existing tests still make sense (Chapter 27)?
- Readability — will the next person (often the original author, six months later) understand this without re-deriving it from scratch?
- Consistency — does it follow the same patterns, naming, and structure already established elsewhere in the codebase?
- Scope — is this PR doing one coherent thing, or has it quietly grown to include unrelated changes that make it harder to review and harder to revert if something's wrong?
A stand-in for GitHub's real line-comment UI on a PR's "Files changed" tab.
Files changed | shopping_list.py
14 def add_item(self, name, price=[]):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
๐ฌ Reviewer comment:
Careful -- mutable default argument (Chapter 25's gotcha).
Every call without an explicit `price` list will share the
same one. Suggest `price=None` and building a fresh list
inside the function if it's None.
[ Reply ] [ Resolve conversation ]
Review summary: ( ) Comment ( ) Approve (โข) Request changes
[ Submit review ]
Notice the shape of that comment: it names the specific problem, explains why it's a problem (not just "this is wrong"), and suggests a concrete fix — that's the difference between feedback someone can act on immediately and feedback that just creates friction. The same principle applies to receiving review:
- A comment is about the code as it currently stands, not a verdict on the author's overall skill — treat "this has a bug" as information, not an attack.
- If a comment is genuinely unclear, ask a clarifying question in the thread rather than guessing at what the reviewer meant.
- Disagreement is normal and fine — explain the reasoning behind your original choice; sometimes the reviewer is missing context, sometimes you are, and either way is resolved by talking it through, not by silently doing what you originally planned.
Thought process: the useful AI-assist here isn't "review my code for me" in a vague sense -- it's asking for a specific, actionable pass (e.g. "check this function against the mutable-default-argument pattern") so the output is something a real human reviewer could also have written, not a generic "looks good" that teaches nothing.
Write the prompt you'd give an AI assistant to help review this PR:
Show a strong version of this prompt
Review this Python method as if you were leaving a code review comment on a GitHub pull request:
def add_item(self, name, price=[]):
self.items.append((name, price))
return self.items
Specifically check for: (1) the mutable default argument gotcha, (2) whether the parameter and variable names are clear, (3) whether this needs a docstring given it's a public method on a class other contributors will use. Write your feedback the way a helpful teammate would -- name the specific issue, explain briefly why it matters, and suggest a concrete fix -- not just "this is wrong."- Reviewers check correctness, test coverage, readability, consistency with existing code, and whether the PR's scope stays focused.
- Approve, Request changes, and Comment are GitHub's three review verdicts — only Request changes blocks a merge by default.
- Good feedback names the specific issue, explains why it matters, and suggests a fix; good receiving treats feedback as information about the code, not the person.
Go Deeper: can a reviewer approve their own PR?
No — GitHub doesn't allow a PR author to approve their own
pull request, precisely because review is meant to be a second
set of eyes. On a solo-maintained repository (like this course's
own, per its CONTRIBUTING.md) that means formal
review often doesn't apply at all; the practice still matters
for any team project, which is why it's taught here regardless.
- Reviewers look for correctness, tests, readability, consistency, and focused scope — not just "does it technically run."
- Comment, Approve, and Request changes are the three verdicts; only Request changes blocks a merge.
- Give feedback that names the issue and suggests a fix; receive it as information about the code, not a judgment of the author.
5. Issues & project workflow
- An issue is a tracked unit of work or a reported problem — a bug report, a feature request, a question, or a task — living on GitHub, separate from any specific branch or PR.
- Labels categorize issues (
bug,enhancement,good first issue); milestones group issues toward a shared deadline or release. - A PR description containing
Closes #42,Fixes #42, orResolves #42links the two and auto-closes the issue the moment that PR is merged.
#42).
A genuinely useful issue answers the questions a contributor would otherwise have to ask before they could even start:
- What's the actual problem or request — specific, not "this is broken."
- Steps to reproduce, for a bug — the exact sequence that triggers it.
- Expected vs. actual behavior — what should have happened, and what actually did.
- Environment, when relevant — Python version, OS, package versions — anything that could explain why it happens on one machine and not another.
A stand-in for GitHub's real "New issue" form and issue page, described in prose/structure rather than captured as a screenshot.
Issues > New issue
Title: ShoppingList.total() crashes on an empty list
## What's happening
Calling .total() on a ShoppingList with zero items raises
ZeroDivisionError instead of returning 0.
## Steps to reproduce
1. cart = ShoppingList()
2. cart.total()
## Expected
Returns 0 for an empty list.
## Actual
Traceback (most recent call last):
ZeroDivisionError: division by zero
## Environment
Python 3.12, macOS
Labels: [ bug ] Milestone: [ v1.1 ] Assignees: [ ]
---
Issue #42 opened 2 days ago ยท 1 comment
Linked pull requests
#57 Add shopping list feature โ will Close this issue on merge
Thought process: a bug report is only as useful as its reproduction steps -- an AI assistant is genuinely good at turning a vague "it's broken" observation into the structured what/steps/expected/actual shape a maintainer can act on immediately, so this is a legitimately strong real-world use of AI assistance, not just a novelty.
Write the prompt you'd give an AI assistant to help write this issue:
Show a strong version of this prompt
I found a bug: calling .total() on an empty ShoppingList raises ZeroDivisionError instead of returning 0. Write this up as a well-structured GitHub issue in markdown with four sections: "## What's happening" (a one-sentence plain description), "## Steps to reproduce" (a numbered list of the exact minimal steps: create an empty ShoppingList, call .total()), "## Expected" (should return 0), and "## Actual" (paste the ZeroDivisionError traceback). Suggest one label ("bug") that fits.bug, enhancement, documentation, good first issue) used to filter and categorize at a glance. A milestone groups a set of issues/PRs under a shared target, usually a release or deadline (v1.1), and shows progress as a fraction (e.g. "6 of 10 closed"). Neither changes any code — both exist purely to keep a growing list of work organized and searchable.
The Closes #42 convention from Sub-topic 3 is the
piece that actually connects issues to the PR workflow: GitHub
scans every PR description and commit message for that phrase
(case-insensitive, several verbs work: close,
closes, closed, fix,
fixes, fixed, resolve,
resolves, resolved, followed by
# and the issue number) and, the moment that PR
merges into the repository's default branch, closes the
referenced issue automatically — no separate step required.
- Issues track work and problems as standalone items, separate from any specific branch or code.
- A useful issue states the problem, reproduction steps, and expected vs. actual behavior — not just "this is broken."
- Labels categorize, milestones group toward a deadline, and
Closes #Nin a PR auto-closes the linked issue on merge.
Go Deeper: do issues have to be bugs?
No — issues are used for feature requests, questions,
documentation gaps, and general discussion just as often as
bugs. Many open-source projects use a good first issue
label specifically to mark small, well-scoped tasks meant to
help new contributors find a manageable place to start, which is
exactly the kind of coordination issues exist to provide.
- An issue is a trackable unit of work/problem, independent of any branch or PR.
- A strong issue states the problem, repro steps, and expected vs. actual behavior.
- Labels categorize, milestones group by deadline, and
Closes #Nlinks a PR to an issue and auto-closes it on merge.
6. A real-world collaboration workflow
- Every piece from Sub-topics 1–5 exists to support one end-to-end loop: someone reports a problem, someone else fixes it, and the fix gets reviewed and merged — visibly, with a full paper trail.
- This sub-topic walks that loop start to finish, using nothing beyond what's already been taught.
Here's the scenario, followed end to end. A user of an open-source
project notices ShoppingList.total() crashes on an
empty list.
1. USER files an issue
-> Issue #42: "ShoppingList.total() crashes on an empty list"
(problem, repro steps, expected vs. actual -- Sub-topic 5)
2. CONTRIBUTOR (no push access) forks the repo on GitHub
-> clones their fork locally (Sub-topic 2)
-> git remote add upstream
3. CONTRIBUTOR branches and fixes it
-> git checkout -b fix-empty-cart-total
-> edits total() to return 0 for an empty list
-> git add . && git commit -m "Fix total() on empty ShoppingList"
-> git push -u origin fix-empty-cart-total (pushes to THEIR fork)
4. CONTRIBUTOR opens a PR
-> base: original repo's main <- compare: their fork's branch
-> description includes "Closes #42" (Sub-topic 3)
5. MAINTAINER reviews
-> line comment: suggests also testing total() with negative
prices, not just the empty-list case
-> verdict: Request changes (Sub-topic 4)
6. CONTRIBUTOR addresses it
-> adds the requested test
-> git commit -m "Add test for negative price edge case"
-> git push origin fix-empty-cart-total (same branch -- PR updates automatically)
7. MAINTAINER re-reviews, approves, merges
-> PR merges into main
-> Issue #42 closes automatically (Closes #42, Sub-topic 5)
-> fix-empty-cart-total branch is deleted (its history lives on in main)
8. CONTRIBUTOR syncs their fork
-> git fetch upstream
-> git merge upstream/main
-> git push origin main (Sub-topic 2)
Every command in that walkthrough was verified for real earlier in this chapter — step 2's remote setup, step 3's branch-and-push, step 6's "push more commits to update the same PR," and step 8's fork sync are exact repeats of the commands already run against the bare-repo stand-in for GitHub, just placed into their real order of use. Nothing in this scenario needed a new git command — it needed knowing when to reach for each one, and that GitHub is the layer recording who reviewed what and why.
Thought process: the useful AI-assist across a whole workflow like this isn't one prompt -- it's knowing which step benefits from help (drafting the issue, drafting the PR description, reviewing the diff before requesting human review) and which steps are just running the right git command, which no assistant should be doing on your behalf without you understanding why.
Write the prompt you'd give an AI assistant for one part of this workflow โ drafting the fix's commit message and PR description together:
Show a strong version of this prompt
I fixed a bug where ShoppingList.total() raised ZeroDivisionError on an empty list instead of returning 0; the fix also adds a test for a negative-price edge case a reviewer requested. Write (1) a concise commit message in the imperative mood ("Fix ...", not "Fixed ..."), following the same convention as Chapter 28's commit messages, and (2) a PR description in markdown with "## What this does", "## Why" (including "Closes #42"), and "## How to test" sections, matching the structure this chapter's lesson used for its own PR description example.One more thing this scenario makes concrete: nothing about it required the contributor to have any special access to the original project. Fork, PR, and review are specifically the mechanism that lets someone with zero write access still get a real fix merged — which is exactly how the overwhelming majority of open-source contributions happen.
- The full loop: issue filed → fork/branch → commit & push → PR opened, linked to the issue → review & revision → merge → issue auto-closes → fork synced.
- Every git command in the loop is one already verified earlier in this chapter — the new skill here is sequencing, not new syntax.
- This is exactly how outside contributors get changes into projects they don't have write access to — the mechanism this whole chapter has been building toward.
Go Deeper: what if the maintainer wants to make a small tweak themselves, right on the contributor's PR?
GitHub supports this directly — a PR from a fork can allow the base repository's maintainers to push commits straight to the contributor's branch (a checkbox on the PR, on by default for most personal-fork PRs), or a maintainer can suggest an exact line change inline that the contributor accepts with one click. Either way, it's still the same branch, still the same PR — just an extra commit added to the loop already shown above.
- Issue → fork/branch → push → PR (linked to the issue) → review → revise → merge → issue auto-closes → fork sync is the complete real-world loop.
- Every command used is one this chapter already ran and verified — the workflow is about sequencing known tools, not new git syntax.
- This exact mechanism is how contributors without write access get real changes merged into any project.
- Every professional software team that uses git also uses something built on top of remotes and PRs — GitHub, GitLab, Bitbucket — specifically because raw git has no concept of review, discussion, or a merge request; that layer is what turns solo version control into team collaboration.
- Open-source projects run entirely on the fork-branch-PR-review loop from Sub-topic 6 — it's the mechanism that lets thousands of strangers contribute to the same codebase without ever needing write access to it.
- "Closes #N" and similar issue-linking conventions aren't cosmetic — they're how real teams keep an accurate, searchable history of why every change happened, which matters enormously months later when someone asks "why was this line added?"
Points to Remember
- A remote is another copy of the repository git knows how to reach;
originis a conventional name, not a keyword.fetchdownloads without touching your branch;pulldownloads and merges in one step. - Clone when you already have write access; fork (on GitHub, then clone) when you don't. Keep a fork in sync by adding the original as
upstream, fetching/merging from it, then pushing to your fork. - A pull request proposes merging a pushed branch into another branch; it lives on GitHub, not git history, until merged. A draft PR is visible but blocked from merging.
- Code review checks correctness, tests, readability, consistency, and scope; Comment/Approve/Request changes are GitHub's three verdicts, and only Request changes blocks a merge.
- Issues track work and problems independent of any branch; labels categorize, milestones group by deadline, and
Closes #Nin a PR auto-closes the linked issue on merge. - The full real-world loop — issue, fork/branch, push, PR, review, revise, merge, sync — is just this chapter's tools used in the right order; it's how virtually all real collaboration, open-source or private, actually happens.