Skip to main content

Initialize a Repo

A repository (repo) is just a folder that Git is watching. This lesson covers turning a plain folder into a Git repo and understanding how Git tracks changes.

The Three Areas of Git

Before touching any commands, understand this mental model — it explains almost every Git command you will ever use.

your filesystemWorkingDirectoryfiles you editright nowgit addthe indexStagingAreachanges you'veselected to commitgit commit.git folderRepositorypermanentcommit history
  • Working Directory — the files you can see and edit. Changes here are "untracked" or "modified" until you stage them.
  • Staging Area — a preparation zone. You choose exactly which changes go into the next commit.
  • Repository — the permanent record. Once committed, a snapshot is saved forever in .git/.

Every Git command moves changes between these three areas.


Create a Project Folder

mkdir my-first-repo && cd my-first-repo

You now have an empty folder. Git knows nothing about it yet.


Initialize the Repo

git init

Output:

Initialized empty Git repository in /path/to/my-first-repo/.git/

This creates a hidden .git/ folder inside your project. That folder is the repository — it stores every snapshot, every branch, every commit. Do not manually edit anything inside .git/.


Check Status

git status

Output:

On branch main

No commits yet

nothing to commit (create/copy files and use "git add" to track)

git status is your compass. Run it constantly — before adding, before committing, when confused. It always tells you exactly where you are and what Git sees.


Create Your First File

echo "# My First Repo" > README.md

Now run git status again:

On branch main

No commits yet

Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md

nothing added to commit but untracked files present (use "git add" to track)

Git sees README.md but is not tracking it yet. It appears under Untracked files — meaning it exists in the Working Directory but has not entered Git's awareness.


Summary

ConceptMeaning
Working DirectoryFiles you can see and edit
Staging AreaChanges queued up for the next commit
RepositoryThe permanent .git/ history
git initTurn a folder into a Git repo
git statusSee what Git currently sees
Donate to this project