๐ŸŒฟ
๐ŸŒฟ Version Control with Git ยท GIT-101 ยท Session 2 of 6

Your First Repository

Git's core loop is just three ideas: a place to track your work (a repo), a staging area, and a commit that saves a snapshot. Get these and you're already using version control.

โฑ 9 min read๐Ÿ“… Updated 2026-07-31๐Ÿ“Š Tables, charts & examples

Git can seem to have a hundred commands, but the everyday core is a simple three-step loop you'll use constantly: create a repository to track a project, add the changes you want to save, and commit them as a snapshot. Once this loop is second nature, you're genuinely doing version control. Let's walk through it with the actual commands.

Init, add, commit

Here's the whole basic workflow - turn a folder into a repo, then save your first snapshot.

git init                 # start tracking this folder

# ... create or edit some files ...

git add .                # stage the changes you want to save
git commit -m "Add my first page"   # save a snapshot, with a message
๐ŸŽฏ
A commit is a labelled snapshot of your whole project at a moment in time. Each commit captures exactly what your files looked like, plus a message saying what changed and why. Your project becomes a series of these snapshots - a timeline you can revisit, compare, or roll back to. The message matters: 'Fix login bug' or 'Add contact form' tells future-you (and teammates) the story of the project. Commit often, in small logical chunks, with clear messages - that's the habit that makes Git powerful.

Why the 'staging area'?

The one part that puzzles beginners is git add - the 'staging area' between your files and a commit. It's actually a useful feature.

StepWhat it means
Working filesYour actual files, as you edit them
git addChoose which changes go in the next commit (stage them)
git commitSave the staged changes as a snapshot
git statusSee what's changed, staged or not - use it constantly

Staging lets you commit some changes but not others - so you can group related work into a clean, meaningful commit even if you've edited several things. When starting out, 'git add .' (stage everything) is fine. And 'git status' is your best friend - run it often to see where things stand.

The loop you'll use forever

  • git init - start tracking a folder as a repository.
  • git add - stage the changes you want in the next snapshot.
  • git commit -m "..." - save the snapshot with a clear message.
  • git status - run it constantly to see what's changed and staged.

๐ŸŽฏ Key takeaways

  • Git's everyday core is a three-step loop: init (make a repo), add (stage changes), commit (save a snapshot).
  • A commit is a labelled snapshot of your whole project - with a message saying what changed and why.
  • The staging area (git add) lets you choose which changes go into the next commit, keeping commits clean.
  • Run 'git status' constantly - it shows what's changed and what's staged.

Frequently asked

What's the point of the staging area - why not just commit my changes directly?

It's the part that confuses almost every beginner, and the short answer is that staging gives you control over what goes into each commit, which lets you keep your history clean and meaningful. Without staging, a commit would just be 'everything that changed since last time', lumped together. With staging, you get an in-between step where you choose which of your current changes to include in the next snapshot. Why does that matter? Because in real work you often edit several unrelated things before committing - you fix a bug, tweak some wording, and start a new feature all in one session. Staging lets you commit just the bug fix as one clean commit (with a message about the bug), then commit the wording change separately, then the feature - instead of one messy commit that mixes three unrelated things. Good, focused commits make your history readable and make it far easier to understand, review, or undo specific changes later. That said, when you're starting out you don't need to agonise over this: using 'git add .' to stage everything and then committing is completely fine and common for simple work, and you can grow into selective staging as your projects get more complex. So the staging area is a feature, not a hurdle - it's Git giving you a chance to curate each snapshot - but you can use it simply at first and appreciate its power later. Think of git add as 'here are the changes I want to save together' and git commit as 'save them now'.

What makes a good commit message, and does it really matter?

It matters more than beginners expect, because commit messages are the story of your project - they're how you (and anyone else) understand what happened and why, sometimes long after the code was written. A good commit message briefly and clearly describes what the commit does, ideally focusing on the intent, not just the mechanics. 'Fix crash when the user list is empty' is excellent: it tells you what changed and why at a glance. 'Add contact form to homepage' is great. By contrast, messages like 'stuff', 'fixes', 'asdf', or 'update' are nearly useless - when you're scanning history six months later trying to find where a bug was introduced, they tell you nothing. A few practical tips: write it in the imperative ('Add', 'Fix', 'Remove', as if completing the sentence 'This commit will...'), keep the summary short and specific (a line is often enough), and if a change is complex, explain the why. It matters because Git's real power - understanding your history, finding when something broke, undoing a specific change, collaborating with others - all depends on being able to read your history, and unreadable messages throw that power away. It costs only a few seconds to write a clear message, and it's a habit that marks the difference between someone using Git as a magic 'save' button and someone using it as the powerful history tool it is. Commit often, in small logical pieces, each with a message that would make sense to a stranger - that discipline pays off constantly.

Session 2 of 6 complete

Next up: Seeing History & Undoing Mistakes

Continue to Session 3 โ†’

Related lessons

More in this course

Course home → · Browse all courses →