C.W.K.
Stream
Lesson 04 of 05 · published

Forks and Pull Requests

~22 min · github, pr, fork

Level 0Untracked Rookie
0 XP0/47 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Forks turn collaboration into request, not push

The fork-and-pull workflow is how the open-source world contributes to projects that contributors do not have direct write access to. The shape: copy the project to your account (a fork), make changes on a branch in your fork, then ask the original maintainers to pull those changes via a Pull Request. The original repo never grants you push access; the PR mechanism is the request-and-review channel that replaces direct push.

Mechanically: GitHub's "Fork" button creates a server-side copy under your account. You clone your fork locally and add the original repo as a second remote, conventionally named upstream. Daily flow: fetch from upstream, sync your fork's main branch, branch off for new work, push the new branch to your fork, open a PR on GitHub. The PR description is where you make the case — what changed, why, how to verify, what risks.

Keeping your fork in sync matters because PRs against an old base produce false conflicts. The clean dance: git fetch upstream, git switch main, git rebase upstream/main, git push origin main. Now your fork's main mirrors the original. Branching off main from this point yields PRs that apply cleanly. GitHub's web UI also offers a "Sync fork" button that does the equivalent without a terminal.

The PR itself is the social product. Title in imperative, ideally with a Conventional Commits prefix. Description with real sections: what, why, how to test, screenshots if visual, breaking changes if any. Link the issue. Keep PRs focused — one concern per PR. Reviewers comment, you push more commits to the same branch (which automatically updates the PR), and once approved, a maintainer merges. After merge, delete the branch on both sides; your fork's main syncs with the new history on next pull.

Code

Fork-clone-branch-PR cycle·bash
# 1. Fork on GitHub (browser), then clone YOUR fork:
git clone git@github.com:YOU/repo.git
cd repo

# 2. Add the original as upstream:
git remote add upstream https://github.com/ORIGINAL/repo.git
git remote -v
# origin    git@github.com:YOU/repo.git
# upstream  https://github.com/ORIGINAL/repo.git

# 3. Branch off the latest upstream main:
git fetch upstream
git switch -c fix/typo-readme upstream/main

# 4. Edit, commit, push to YOUR fork:
git add README.md
git commit -m "docs: fix install command typo"
git push -u origin fix/typo-readme

# 5. Open a PR on GitHub from YOU:fix/typo-readme to ORIGINAL:main
Keep your fork's main in sync·bash
git fetch upstream
git switch main
git rebase upstream/main      # or merge — pick the project's policy
git push origin main          # sync your fork's main on GitHub

# Repeat before starting any new branch off main

External links

Exercise

Fork any small open-source project on GitHub. Clone your fork, add upstream, sync main. Create a branch with a tiny doc-style change (typo, README clarification). Push to your fork and open a PR. Walk through the PR template fields and write a real description with what/why/how-to-verify sections. You do not have to ship the PR; observe the workflow end to end.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.