Cloning a Repository
Cloning downloads a repository with its full history and connects it to GitHub so you can push and pull.
On this page · 5 min · Beginner
On this page
- Learning objectives
- Explanation
- Step-by-step screens
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Nov 25, 2026
Learning objectives#
- Find the clone URL
- Clone with the terminal and with VS Code
- Choose HTTPS or SSH
- Know how clone differs from Download ZIP
Explanation#
On the repository page, the green <> Code button shows the clone URL. HTTPS works everywhere and signs in through your browser the first time (Git Credential Manager on Windows). SSH uses a key you add to GitHub once and never asks again.
git clone <url> creates a folder with the repository name, downloads every commit and sets up a remote called origin pointing back to GitHub.
In VS Code: Ctrl+Shift+P → Git: Clone → paste the URL → choose a parent folder → Open. GitHub Desktop has File → Clone repository, with a list of your repositories.
Download ZIP gives you only the files: no history and no connection to GitHub. Use it to look at code, not to work on it.
Step-by-step screens#
Drawings of github.com, the Git installer, VS Code and a terminal. GitHub changes its layout from time to time; the button names stay the same. The red numbers match the numbered actions under each picture; names on your computer will differ.
Loading pictures…
Code example: Clone and look around#
cd C:\dev
git clone https://github.com/asha/hello-github.git
cd hello-github
git remote -v
git log --oneline -3
Cloning into 'hello-github'... remote: Enumerating objects: 12, done. Receiving objects: 100% (12/12), done. origin https://github.com/asha/hello-github.git (fetch) origin https://github.com/asha/hello-github.git (push) 3f9c2a1 Add a welcome line 8d41e07 Add style.css 1a2b3c4 Initial commit
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- Choose a folder for your projects first.
- git clone downloads and creates hello-github/.
- origin is the name of the GitHub copy.
- git log shows the history came along too.
Real-world use case#
A new team member clones the company repository on day one and runs the project without anyone emailing zip files.
Common mistakes#
A repo inside a repo confuses Git. Keep projects side by side in a folder such as C:\dev.
There is no history and you can’t push. Clone instead.
Best practices#
- Keep all projects in one folder (C:\dev)
- Use SSH once you push often
- Never work from a ZIP
- Pull before you start each day
Remember this#
<> Code → copy URL.
git clone URL.
origin = GitHub copy.
Practice exercise#
Your task: Show where your repository pushes to.
Show solution
git remote -v
Mini quiz#
What does Download ZIP not give you?
Want more? Practise all Git & GitHub MCQs · Git & GitHub interview questions
My notes#
Saved in this browser.