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:
| State | Meaning |
|---|---|
| Untracked | Git doesn't know about this file yet |
| Tracked | Git is watching this file for changes |
| Modified | You've changed the file since last snapshot |
| Staged | Ready 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!
git init in the terminal