🔥 0
0
Lesson 2 of 10 20 min +100 XP

Your First Repository

A repository (or "repo") is simply a folder that Git is tracking. Let's create one!

Creating a Repository

To turn any folder into a Git repository, you use:

git init

That's it! This single command transforms an ordinary folder into a version-controlled project.

What Happens When You Run git init?

When you initialize a repository, Git creates a hidden .git folder inside your project. This folder contains:

  • All your project history - every snapshot you've ever taken
  • Branch information - which timelines exist
  • Configuration - settings for this repository
my-project/
├── .git/          ← Git's brain (hidden folder)
│   ├── objects/   ← Stores all your snapshots
│   ├── refs/      ← Tracks branches
│   └── HEAD       ← Points to current branch
├── index.html
├── style.css
└── app.js

The Working Directory

Your working directory is everything in your project folder except the .git folder. This is where you actually edit files.

Git constantly watches your working directory to see what's changed since your last snapshot.

Repository States

Files in a Git repository can be in one of these states:

StateMeaning
UntrackedGit doesn't know about this file yet
TrackedGit is watching this file for changes
ModifiedYou've changed the file since last snapshot
StagedReady to be included in next snapshot

Try It Out!

Use the interactive simulator below to initialize a repository. Watch as the .git folder appears and Git starts tracking your project!

Visual Mode: Click the "Initialize Repository" button Command Mode: Type git init in the terminal
What is Version Control?