Back to Learning Path

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:

bash
cd Desktop

Step 3: Clone the repository

Use the git clone command with the URL you copied:

bash
git clone https://github.com/username/repo-name.git

Git will create a new folder with the repository name and download everything.

Step 4: Start working

Enter the new directory:

bash
cd repo-name

Now 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:

bash
git clone https://github.com/github/gitignore.git

This 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