Master Git & GitHub From Scratch

Clear, practical, and structured lessons designed to take you from Git fundamentals to real-world GitHub collaboration.

Cloning a Repository / Project

It downloads a copy of an existing remote Git repository, such as a repository hosted on GitHub or GitLab, to your local computer. It is usually the first step when starting work on an existing project.

The correct command is git clone.

Learn how to get a repository URL, clone a project using Command Prompt or GitHub Desktop, and understand the difference between cloning and downloading a ZIP.


1. Get the Repository URL from GitHub

  1. Open the repository's main page on GitHub.
  2. Click the green Code button.
  3. Select the HTTPS tab.
  4. Copy the repository URL.

Example URL:

https://github.com/username/project.git
Tip: Replace the example URL with the URL copied from the repository you want to clone.

2. Clone Using Command Prompt (CMD)

Step 1: Open the Destination Folder

Open Command Prompt and navigate to the directory where you want to save the project.

cd Documents\MyProjects

Make sure this directory exists before running the command.

Step 2: Clone the Repository
git clone https://github.com/username/project.git

Git creates a new folder for the repository and downloads its files and Git history.

Step 3: Open the Project Folder
cd project

You can now inspect the project or open it in your preferred code editor.

Note: Git must be installed on your computer and available from Command Prompt. Check this using git --version.

3. Clone Using GitHub Desktop

GitHub Desktop provides a graphical interface for cloning repositories without typing Git commands.

  1. Open the GitHub Desktop application.
  2. Click File → Clone repository.
  3. Select the GitHub.com tab to choose a listed repository, or select the URL tab to paste a repository URL.
  4. Choose the local path where you want to store the project.
  5. Click Clone.

GitHub Desktop downloads the repository into your selected local folder.


4. What Happens When You Run git clone?

Git automatically performs these main tasks:

  1. Downloads the project's files and available repository history.
  2. Creates a local Git repository with the available branch and commit history.
  3. Configures a remote named origin pointing to the source repository.

Basic syntax:

git clone <repository-url>

Example:

git clone https://github.com/username/nodeJSApplication.git

This creates a local folder named nodeJSApplication containing the repository's files and Git history.


5. Git Clone vs Download ZIP

Downloading a ZIP is useful when you only need a snapshot of the source code. Cloning is better when you plan to develop the project, track changes, or collaborate with others.

Feature Download ZIP Git Clone
Best For One-time viewing or inspection Development and collaboration
Git Connection No Git remote configuration Configured with the source remote
Getting Updates Download another ZIP Use commands such as git pull
Sending Updates No Git history to push from the ZIP alone Can push commits if you have permission
Commit History Not included in the ZIP snapshot Repository history is available
Key Takeaway: Use git clone when you want a local repository with its Git history and remote connection. Download a ZIP when you only need the source files for quick inspection.