Repositories

What is a repository?

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.

Starting a new repo with 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

Terminal
$ cd path/to/your-project
$ git init
In VS Code
  1. Open your project folder in VS Code (File → Open Folder)
  2. Open the Source Control panel
  3. Click Initialize Repository

After this, Git is tracking the folder — but no snapshots exist yet until you commit.

Copying an existing repo with 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

Terminal
$ git clone https://github.com/user/project.git
In VS Code
  1. Open the Command Palette (Ctrl+Shift+P)
  2. Type Git: Clone and press Enter
  3. Paste the repository URL and choose where to save it

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.

Checking the state of a repo

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

Terminal
$ git status
In VS Code
  1. Just look at the Source Control panel — it lists changed files automatically
  2. A number badge on the icon shows how many files changed

Up next: the heart of Git — staging with add and saving with commit.

FAQ

Frequently Asked Questions

What is the difference between git init and git clone?
git init starts tracking a folder you already have on your computer. git clone downloads an existing repository — with its full history — from GitHub.
What is the difference between cloning and downloading the ZIP?
GitHub's "Download ZIP" gives you only the current files — no history, no Git connection. git clone gives you the full repository: every commit, every branch, and a working link to push and pull.
What's inside the .git folder?
The entire history of your project — every commit, branch and setting, stored in Git's own format. You never edit it by hand; the git commands are the interface to it.
Is it safe to delete the .git folder?
It removes the entire version history but leaves your current files untouched. Only do it if you genuinely want to stop using Git for that folder.