git clone
Copy an entire repository — history, refs, branches — to your machine.
git cloneWhat it does
git clone connects to a remote, downloads every object in its object store, and reconstructs the repository locally: all commits, all trees, all blobs, all tags. It then checks out the default branch so you have a working copy, and records the source as origin.
Your machine
local repository
Remote origin
everything.git
The remote's whole object database streams down; a copy is materialized
Watch it — press play
A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.
Step 1
Grab the whole project
You point at a remote URL. Everything — every commit, branch, tag — is about to flow down to you.
git clone git@github.com:user/repo.gitYour machine
local repository
Remote origin
everything.git
The object database streams down
Under the hood
It's a fetch plus a checkout
Under the hood, clone = git fetch (download all reachable objects into your local object store) + git checkout (materialize the default branch into a working tree). One command, two classic operations.
Remote-tracking refs are created
Clone writes refs/remotes/origin/main pointing at the remote's default branch, and sets main's upstream to origin/main. That wiring is what makes 'ahead/behind' and straightforward git pull work from day one.
All of history comes down
Cloning is full-depth by default: every commit, blob and tree arrives as loose objects or packfiles. That's why your .git folder is often bigger than the checkout — it holds the entire past of the project.
--depth skips history for speed
Shallow clones (--depth 1) download only one commit's worth of objects. Great for a quick look, a tax later: many operations lose reachability context and need --unshallow to heal.
Command anatomy
<url>HTTPS or SSH URL (https://github.com/org/repo.git).
--depth 1Shallow clone — just the latest snapshot.
--branch <b>Skip to a specific branch as the initial checkout.
--bareMirror the repo with no working directory (server-side).
When to reach for it
Grabbing a project to work on: git clone git@github.com:user/repo.git.
Creating a backup mirror of a repo with --bare or --mirror.
Speeding up CI by shallow-cloning in build images.
Practice
A real repo, pre-seeded with history, runs right here — stage, commit, branch, stash, diff, even hit and resolve a real merge conflict. Nothing to install, nothing leaves your machine.
Open practice playground