Tour of Git
Working with Remotes / Lesson 4.2

git clone — Copying a Repository

The git clone command creates a local copy of a remote repository. It downloads all commits, branches, and files, and sets up a connection back to the source.

What Clone Does

  1. Creates a new directory
  2. Initializes a Git repository inside it
  3. Adds the source as a remote called origin
  4. Downloads all commits and branches
  5. Checks out the default branch (usually main)

Basic Usage

git clone https://github.com/user/project.git

Try it!

Clone a simulated remote repository:

  1. Clone the repo: git clone https://github.com/example/project.git
  2. Check the remote: git remote -v
  3. View the commit history: git log --oneline
  4. List files: ls

Notice that git remote -v shows origin pointing to the URL you cloned from.

After Cloning

Once cloned, you can:

  • Make changes and commit locally
  • Push your commits back with git push
  • Pull updates from others with git pull

The clone is a full copy — you have the entire history, not just the latest files.

🎯

Goal

Clone the remote repository and verify you have the files and history

Terminal
$

No commits yet. Run `git init` and create your first commit.