Whenever we want to work on a project from GitHub, the first step is to clone it — download a complete copy of the repository into our computer. Once we clone a repo, we can freely edit files, run the project locally, create commits, and push changes back to GitHub.
In this guide, we’ll walk through how to clone a repository the right way, using the latest GitHub interface and three available cloning options: HTTPS, SSH, and GitHub CLI.
1. What Does “Cloning” Mean?
When we clone a repository, Git:
- Downloads all files
- Copies the complete commit history
- Connects our local machine to the remote repo
- Lets us start working locally right away
After cloning, our computer has a fully functional Git project.
2. Where We Find the Clone Options on GitHub
On any GitHub repository page, we click the green <> Code button.

We’ll see two tabs:

A. Local
This is where GitHub gives us three cloning options:
- HTTPS
- SSH
- GitHub CLI
B. Codespaces
This opens GitHub’s cloud-based development environment.
(Not for local cloning.)
For working locally, we always stay on the Local tab.
3. Cloning Using HTTPS (Our Easiest Starting Point)
HTTPS is the simplest and most beginner-friendly method.
We can start using Git immediately without setting up keys.
Steps
- Click Code → Local → HTTPS
- Copy the HTTPS link:
https://github.com/username/repository.git - Run this command in our terminal:
git clone https://github.com/username/repository.git - Go into the project folder:
cd repository
When we should use HTTPS
- We are beginners
- We are behind a firewall or school/office network
- We want the simplest setup
When we push changes, Git may ask us for a Personal Access Token instead of a password.
That’s normal now.
4. Cloning Using SSH (Great for Frequent Contributors Like Us)
SSH uses key-based authentication. Once we set it up, Git will stop asking for credentials again and again.
Steps
- Click Code → Local → SSH
- Copy the SSH link:
git@github.com:username/repository.git - Clone the repo:
git clone git@github.com:username/repository.git - Move into the folder:
cd repository
When we should use SSH
- We push and pull often
- We want a secure, password-free workflow
- We work on multiple repositories
- We use automation or CI/CD
SSH is perfect for those of us who code regularly.
5. Cloning Using GitHub CLI (Perfect if We Love Terminal Work)
GitHub CLI (gh) is a powerful tool if we prefer command-line workflows.
Steps
- Install GitHub CLI
- Log in:
gh auth login - Clone the repo:
gh repo clone username/repository
When we should use GitHub CLI
- We enjoy working fully in the terminal
- We want fast authentication
- We use GitHub features like issues and PRs from the CLI
For advanced students, this becomes the easiest method.
6. Which Cloning Method Should We Choose?
Here’s a simple guide:
| Our Situation | Best Method |
|---|---|
| We are beginners | HTTPS |
| We are behind a firewall or proxy | HTTPS |
| We push and pull daily | SSH |
| We use scripts or automation | SSH |
| We prefer command-line tools | GitHub CLI |
All three methods are secure. We simply pick what suits our workflow or just what we are more comfortable with.
7. Optional: Faster Cloning With Shallow Copy
If we don’t need the full history:
git clone --depth 1 <url>
This saves time and disk space.
8. Optional: Cloning Only Part of a Repository
For huge repositories, we can clone only the folder we need:
git clone --filter=blob:none <url>
cd repo
git sparse-checkout init --cone
git sparse-checkout set folder-name
9. Summary
- We click Code → Local to find the cloning options
- GitHub offers HTTPS, SSH, and GitHub CLI
- HTTPS → simplest
- SSH → best for frequent contributors
- CLI → best for power users
- We can switch methods later if needed
Cloning is the first step in becoming confident with Git and GitHub.
Once we know how to clone a repo, we can start building, experimenting, and contributing with ease.
References
- GitHub Docs — “Cloning a repository”
- GitHub Docs — “Which remote URL should I use?”
- GitHub Docs — “Connecting to GitHub with SSH”
- GitHub CLI Documentation