learn git.
0/25 done
learn git/remotes and beyond/course 21 of 25

git clone: download a whole project

Files and complete history, in one command.

6 min read·3 sections·3 tasks
the key idea

git clone downloads a remote repository — every file and every commit — and wires up the remote for you.

01What clone does

You found a project on GitHub and want to work on it. git clone <url> downloads it — and this is the part people underrate: not just today's files, but the entire photo album. Every commit anyone ever made on that project, the whole story, lands on your disk in one go.

That is why cloning feels heavy the first time and instant afterwards — the history is real data. And it is why you can explore a cloned project's past offline, on a plane, in a tunnel: the album came with you.

[bash]· the whole project, history included
git clone https://github.com/flawme/demo-project.git

02What you get

Clone creates a new folder named after the project, puts the current files inside, and — the detail that saves you three commands — remembers where it all came from. The remote origin is already connected, so you can push your changes back or pull updates immediately. No git init, no git remote add: clone did everything.

The first moves inside a fresh clone are the natural ones: ls to see what is here, cat README.md to read the instructions the author left, git log --oneline to see the story so far. You are holding a complete copy of a project that took other people years — treat the log like a book's table of contents.

  • —the files — the current state of the project
  • —the history — every commit, readable offline
  • —origin — the remote, already configured
Clone versus download-zip

A zip download gives you the files only — a snapshot with no memory. Clone gives you the files plus the album plus the connection. Same size, different object entirely.

03The difference from init

git init starts a brand-new album from nothing. git clone copies an existing one. Every repository you ever touch will have begun one of those two ways, and you can tell which by looking: a cloned repository already has commits and a configured remote; an inited one starts empty and alone.

Clone is read-write, not read-only

A clone is a full repository, not a view of one. You can commit to it freely. Whether your commits can be pushed back depends on permissions — that is a GitHub matter, not a git one.

>>

Practice

A tiny project is hosted at a fake URL. Bring it home.

[practice]· a real terminal, safely simulated
practice terminal — everything here is simulated, nothing can break
type 'help' to see the commands this terminal understands
~/my-project $
Your tasks0/3 done
  1. 01.Clone https://github.com/flawme/demo-project.git

    hint: Type: git clone https://github.com/flawme/demo-project.git

  2. 02.Confirm the files arrived — look around.

    hint: Try: ls then cat README.md

  3. 03.Read the project's history.

    hint: Try: git log --oneline