Progress:
TIER 1 · MODULE 02· Basics

git clone

Mirror a remote repo onto your disk, refs and all.

🎯 What & why

Make a local copy of a remote repository — every commit, every branch's history, the whole object database — and check out a working tree from it. Equivalent to init + remote add origin + fetch + checkout, in one shot.

🧠 Mental model

Clone copies the entire .git/ from the source over the wire (or filesystem), then writes one branch's tree to the working directory. The remote's branches are recorded as remotes/origin/ refs locally; you only have a local* branch for the one you're checked out on. Everything else is one git switch away.

🛠️ Synopsis

git clone [<options>] <repository> [<directory>]

🎚️ Switches & options

FlagWhat it does
--branch=<name>, -bCheck out a specific branch (or tag) instead of the default.
--depth=<n>Shallow clone — only the last n commits per branch. Faster, smaller. Limits history operations.
--single-branchFetch only the branch you're checking out. Combine with --depth for tiny clones.
--filter=blob:nonePartial clone: skip blobs at clone time, fetch on demand. Good for huge repos.
--bareClone as bare — no working tree.
--mirrorLike --bare but also mirrors all refs 1:1, including notes and remote-tracking refs. For backup mirrors.
--recurse-submodulesInitialize and clone submodules too.
--origin <name>, -oName the remote something other than origin.
--no-checkout, -nDon't pull files into the working tree. Cheap setup before sparse-checkout.

💡 Use cases

🧪 Examples

Standard clone over SSH.
$ git clone git@github.com:user/proj.git
$ cd proj
Shallow clone — last commit only — for a CI build.
$ git clone --depth=1 https://example.com/repo.git build/
Partial clone (blobs on demand). Works well for monorepos.
$ git clone --filter=blob:none https://example.com/big-repo.git
Mirror clone for periodic backup.
$ git clone --mirror git@host:repos/proj.git proj.git
# Later: cd proj.git && git remote update

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.