Step 9: Clone a Repository
Cloning means downloading a copy of a repository from GitHub to your computer. It's how you start working on existing projects.
What is Cloning?
When you clone a repository, you create an exact copy on your local machine. This includes all files, commit history, and branches.
Think of it like:
Downloading a Google Doc to edit offline — you get the full document with all its history.
How to Clone a Repository
Step 1: Get the repository URL
- Go to the repository on GitHub
- Click the green "Code" button
- Copy the HTTPS URL (starts with https://)
Step 2: Open your terminal
Navigate to where you want to save the project:
cd DesktopStep 3: Clone the repository
Use the git clone command with the URL you copied:
git clone https://github.com/username/repo-name.gitGit will create a new folder with the repository name and download everything.
Step 4: Start working
Enter the new directory:
cd repo-nameNow you can make changes, create branches, and commit!
When to Clone
- •Contributing to open source — Clone the project to add features or fix bugs
- •Working with a team — Clone your team's project to start collaborating
- •Working on new machine — Clone your own projects to work on different computers
- •Learning from examples — Clone projects to study how they work
Try It Yourself
Practice by cloning this example repository:
git clone https://github.com/github/gitignore.gitThis is GitHub's official repository of .gitignore templates — safe to clone and explore!
Clone vs Fork: What's the Difference?
Clone
Downloads a copy to your computer. You work locally. Good for projects you have permission to push to.
Fork
Creates your own copy on GitHub. Good for contributing to projects you don't own. You can then clone your fork.
Quick Summary
- Cloning downloads a repository to your computer
- Use
git clone <url>command - Get the URL from GitHub's green Code button
- Creates a new folder with all project files