Skip to content
Beginner GitLesson 1 of 5 2 min read

Git Fundamentals

What version control actually is, and the three places git keeps track of your files.

On this page4 sections

Version control is a system for recording changes to a set of files over time, so you can review what changed, revert a mistake, and work alongside other people without overwriting each other's work. git is, by a huge margin, the version control system the industry standardized on.

Three places, one file

At any moment, a file you're tracking with git exists in up to three places:

AreaWhat it holds
Working directoryThe files as they currently sit on disk - whatever you're editing right now.
Staging area (the "index")Changes you've marked as ready for the next commit, via git add.
RepositoryThe permanent history - every commit you've ever made, via git commit.

Nothing becomes permanent until it's committed, and nothing gets committed until it's staged first. That two-step "stage, then commit" process is deliberate: it lets you build one coherent commit out of several edits, instead of every single save becoming its own entry in the history.

Starting a repository

bash
git init

This creates a hidden .git directory in the current folder - that's the entire repository, holding every commit, branch, and bit of history git will ever track here. Delete .git and, as far as git is concerned, the history never existed.

Checking where you stand

bash
git status

This is the single most-run git command there is. It reports, in plain English, what's changed in your working directory, what's staged and ready to commit, and what git isn't tracking at all yet.

Try it

Run these in the practice terminal (opens in a new tab). It opens in a new tab, so you keep your place here.
bash
git init

When you're ready, hit Mark complete and move to the next lesson.

Challenge

Initialize a new git repository in the current directory.

Want to experiment first? Try things in the practice terminal (opens in a new tab), then enter the command that solves the task here.

Quiz

Lock in the concepts. Score at least 80% to mark the lesson complete.

0 of 2 answered

Done with this one?

Skipped the challenge? You can mark the lesson complete by hand.

Your notes

Kept on this browser only.