CurriculumGitHub FundamentalsForking a Repository
Lesson 3 of 838%
Intermediate7 min+70 XP

Forking a Repository

A fork is your own GitHub copy of someone else's repository. Forking lets you freely experiment and make changes, then propose those changes back to the original via a Pull Request — the foundation of all open source contribution on GitHub.

01.Fork vs Clone: Know the Difference

Clone creates a local copy on your machine. Fork creates a copy on GitHub under your account. For repos you own or are a collaborator on: clone directly and push branches. For repos you have no write access to (most open source): fork first to get your own copy on GitHub, then clone your fork, make changes, and open a PR to the original.

Distributed Architecture
💻
Your Local
push / pull
☁️
GitHub (Remote)
push / pull
💻
Teammate's Local

02.The Complete Fork Contribution Workflow

Step 1: Click "Fork" on GitHub — creates a copy at YOUR_USERNAME/repo. Step 2: Clone YOUR fork to your machine. Step 3: Add the original as "upstream" remote. Step 4: Create a descriptive branch. Step 5: Make your changes and commit. Step 6: Push your branch to your fork (origin). Step 7: Click "Compare & pull request" on GitHub to propose the change.

Branch Visualization
featuremainHEAD
main
feature
HEAD

Commands

commands — click to reveal output
$
# Click "Fork" button on GitHub
Creates YOUR_USERNAME/repo-name on your account
$
git clone https://github.com/YOUR_USER/forked-repo.git
Clone YOUR fork (not the original!)
$
cd forked-repo
Enter the project folder
$
git remote add upstream https://github.com/ORIGINAL_USER/repo.git
Add original as upstream for staying in sync
$
git checkout -b fix/my-contribution
Create a branch for your specific change
$
git push origin fix/my-contribution
Push your branch to your fork on GitHub
$
# Open PR on GitHub: your fork → original repo
Propose your change to the maintainers
KNOWLEDGE CHECK

When should you fork instead of just cloning?

Rate this lesson:
PreviousNext Lesson