Algocraft / Git Commands / git init & clone

🌱

git init & git clone

Two ways to get a repository started: an empty one with no history, or a full copy of one that already exists

Unborn Branch .git Directory Remote Tracking
Commit Graph Step 0 / 0
Working Directory → Staging → Repository
Terminal Transcript

Key Concepts

🎯 When to Use
  • init: starting a brand-new project from scratch
  • clone: joining a project that already lives on GitHub/GitLab/etc.
⚖️ What Actually Happens
  • init creates a .git folder and an unborn main ref — zero commits
  • clone downloads every commit, creates local main, and wires up origin tracking automatically
🎓 Pro Tips
  • A repo with zero commits can't have a second branch yet — there's nothing to point it at
  • git clone --depth 1 grabs only the latest commit for a faster, shallow clone