Chapter 33: Git Clone from GitHub
Git clone from GitHub
This is the command that says:
“Hey GitHub, give me a complete copy of that repository so I can work on it on my laptop.”
Many beginners confuse clone with fork, or with download ZIP, or think “why do I need clone if I can just edit on GitHub.com?”
Today I’m going to explain git clone very clearly and slowly — like I’m sitting right next to you with your terminal and browser open — with real commands, exact outputs you’ll see, common mistakes, and a complete realistic example you can follow right now.
1. What does “git clone from GitHub” actually do?
git clone = “download an entire Git repository (including full history) from a remote location to your computer”
More precisely:
- It creates a new local folder on your laptop
- Copies all files from the latest state of the chosen branch
- Downloads the complete commit history (every snapshot ever made)
- Sets up a remote connection called origin pointing back to the GitHub URL
- Sets up tracking so git pull / git push know where to go
Analogy most people love:
- GitHub repo = a book in a public library
- git clone = you borrow the book + make a full photocopy of every page + bring it home
- Now you have your own copy to read, highlight, write notes in — and the library book stays untouched
Important differences in 2026:
| Action | What you get on your laptop | History included? | Can you push back easily? | Use when… |
|---|---|---|---|---|
| GitHub “Download ZIP” | Just the current files (no .git folder) | No | No — no history, no push | Quick look, no Git work |
| git clone | Full repo + full history + .git folder | Yes | Yes (if you have permission) | Real development, contributing, forking |
| Fork + clone your fork | Full copy under your account + full history | Yes | Yes — to your fork | Contributing to someone else’s project |
2. Two main ways to clone (HTTPS vs SSH)
You can clone with either protocol — both work perfectly in 2026.
HTTPS (easier for beginners, asks PAT sometimes)
|
0 1 2 3 4 5 6 |
https://github.com/username/repo-name.git |
SSH (passwordless after setup, recommended for daily use)
|
0 1 2 3 4 5 6 |
git@github.com:username/repo-name.git |
(If you haven’t set up SSH yet — go back to our “Git Security SSH” lesson)
3. Realistic Example – Clone a real repo right now
Let’s clone a popular, beginner-friendly open-source project:
Repository: https://github.com/public-apis/public-apis (A huge curated list of free APIs — great for learning)
Step 1 – Choose where to save it
Make a folder where you keep projects:
|
0 1 2 3 4 5 6 7 |
mkdir ~/projects cd ~/projects |
Step 2 – Clone with HTTPS (easiest first time)
|
0 1 2 3 4 5 6 |
git clone https://github.com/public-apis/public-apis.git |
You’ll see something like this:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 |
Cloning into 'public-apis'... remote: Enumerating objects: 12345, done. remote: Counting objects: 100% (12345/12345), done. remote: Compressing objects: 100% (5678/5678), done. remote: Total 54321 (delta 9876), reused 43210 (delta 8765), pack-reused 0 Receiving objects: 100% (54321/54321), 1.23 MiB | 2.34 MiB/s, done. Resolving deltas: 100% (9876/9876), done. |
→ It created folder public-apis with all files + full history
Step 3 – Go inside & look around
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
cd public-apis ls # you see README.md, CONTRIBUTING.md, etc. git log --oneline -5 # shows last 5 commits with messages & authors git remote -v # shows: origin https://github.com/public-apis/public-apis.git (fetch) origin https://github.com/public-apis/public-apis.git (push) |
Step 4 – Make a change (optional – just for feeling)
Edit README.md → add one line at the bottom:
|
0 1 2 3 4 5 6 |
Thanks for this awesome list! Learning a lot in Hyderabad 2026. |
Then:
|
0 1 2 3 4 5 6 7 |
git add README.md git commit -m "docs: add personal thank you note" |
You can’t push this back to the original (no permission) — but if you forked first, you could push to your fork.
Step 5 – Update later (pull new changes)
Weeks later someone added 10 new APIs:
|
0 1 2 3 4 5 6 7 |
git switch main git pull origin main |
→ Your local copy now has the latest version.
4. Clone + Fork combo (most common for contributing)
Real flow most people do:
- Go to repo → Fork (creates your copy on GitHub)
- Clone your fork:
|
0 1 2 3 4 5 6 |
git clone https://github.com/your-username/public-apis.git |
- Add original as upstream (so you can pull updates):
|
0 1 2 3 4 5 6 |
git remote add upstream https://github.com/public-apis/public-apis.git |
- Now you can:
|
0 1 2 3 4 5 6 7 |
git fetch upstream git merge upstream/main # update your main from original |
5. Quick git clone Cheat Sheet (2026)
| What you want to do | Command Example | Notes |
|---|---|---|
| Clone with HTTPS | git clone https://github.com/user/repo.git | Easiest, may ask PAT |
| Clone with SSH | git clone git@github.com:user/repo.git | Passwordless after SSH setup |
| Clone into specific folder name | git clone https://… my-custom-name | Changes folder name |
| Clone only latest commit (shallow) | git clone –depth 1 https://… | Much faster for huge repos, no full history |
| Clone specific branch only | git clone -b develop https://… | Gets only that branch |
| Update after clone | git pull or git pull origin main | Gets new commits |
Got the clone feeling now?
git clone from GitHub = “bring the full repo + history to my laptop so I can work on it locally”
Next?
- Want to clone your fork + add upstream + sync with original?
- How to clone a very large repo efficiently?
- Or move to making your first pull request after clone?
Just tell me — we’ll keep going step by step. You’re doing excellent! 🚀
