git init starts tracking a folder you already have on your computer. git clone downloads an existing repository — with its full history — from GitHub.Guide
A repository is just a project that Git is watching. Here's how to start or copy one.
A repository (everyone says "repo") is a folder that Git is tracking.
Inside it, Git keeps a hidden folder called .git that stores the entire
history — every commit, branch and snapshot. You almost never touch .git
directly; just know that deleting it removes the history while leaving your files.
There are two ways you'll get a repo: start a brand-new one, or copy an existing one.
init
If you have a project folder that isn't tracked yet, git init turns it into a
repository. It creates the .git folder and starts watching for changes.
Turn a folder into a repo
$ cd path/to/your-project
$ git init File → Open Folder)After this, Git is tracking the folder — but no snapshots exist yet until you commit.
clone
Most of the time you'll work with code that already lives on GitHub. git clone
downloads a full copy — history and all — to your machine.
Download a GitHub repo
$ git clone https://github.com/user/project.git Ctrl+Shift+P)You get the URL from the green 'Code' button on any GitHub repo — it offers an HTTPS or an SSH address. HTTPS is simplest to start; see the Setup chapter for authentication.
Keep the junk out: some files — secrets, node_modules, build output — should never be committed. Ignore Files (.gitignore) covers the ignore file, its pattern syntax, and untracking a file committed by mistake.
Whenever you're unsure what's going on, git status is your friend. It tells you
which files changed, what's staged, and which branch you're on. You'll use it constantly.
See what's going on
$ git status Up next: the heart of Git — staging with add and saving with commit.
FAQ
git init starts tracking a folder you already have on your computer. git clone downloads an existing repository — with its full history — from GitHub.git clone gives you the full repository: every commit, every branch, and a working link to push and pull.git commands are the interface to it.