Skip to content
zero2vibecodelearn vibe coding
Level 4 · Tools and version control 7 min Reviewed by the author · Aug 4, 2026

Your first commit: git init, status, add, commit

Four commands take a folder from "just files" to a project with saved history: init, status, add, commit.

Level 4 · 0 / 4 lessons0%

records the history of a folder. Every time you save a snapshot, it remembers exactly what every file looked like — and lets you go back.

This is the safety net under every AI coding session. When an agent rewrites twelve files and the result is worse, "go back to the last " is a one-line answer instead of an afternoon.

git init — start tracking

git init
Initialized empty Git repository in /home/user/myproject/.git/

That created a hidden .git folder. Your files are untouched; git has simply started paying attention to them. Nothing has been uploaded anywhere — this is entirely local.

Note

Git and GitHub are different things. Git is the program on your machine that records history. GitHub is a website that hosts copies of git repositories. You can use git for years without ever touching GitHub.

Quick check

After git init, where does your project live?

git status — where do I stand

git status
On branch main
Untracked files:
	index.html
	style.css

Two files exist and git is not looking after either of them yet. Untracked means “I can see it, but I have never been told to record it”.

git status is the pwd of git. Run it before you do anything and after you do anything. It is free, it changes nothing, and it always tells you the truth about where you are.

Quick check

Which git command is safe to run at literally any time?

git add — choose what goes in

git add .

The . means “everything in this folder”. Run git status again:

On branch main
Changes to be committed:
	new file:   index.html
	new file:   style.css

The files have moved to staged — a waiting room for the next commit.

Why the extra step? Because you often change several unrelated things before you think to save. Staging lets you commit the bug fix by itself, then the styling change by itself, so the history reads as a series of decisions rather than a pile of Tuesdays.

git add index.html

stages just that one file.

Quick check

You fixed a bug and also renamed some variables. How do you record just the bug fix?

git commit — save the snapshot

git commit -m "first commit"
[main 0a1b2c3] first commit
 2 files changed

The -m flag carries the message. That message is what you will read in six months when you are trying to work out what happened, so make it say what changed and why:

  • Bad: update, fix, stuff
  • Good: add the contact form, fix the crash on empty search

Tip

Write the message as if finishing the sentence “this commit will…”. “This commit will add the contact form.” It keeps you in the habit of describing a change rather than naming a file.

Run git status one more time:

On branch main
nothing to commit, working tree clean

Everything on disk matches the last saved snapshot. That sentence is the calmest one in software.

Quick check

What does 'nothing to commit, working tree clean' mean?

Try it

Note

Git here is simulated. The workflow, the states and the messages match the real thing closely enough to build the habit, but no repository is created on your machine.

  1. git init — start tracking.
  2. git status — two untracked files.
  3. git add . — stage them both.
  4. git status — same files, now staged.
  5. git commit -m "first commit" — save the snapshot.
  6. git status — clean.

Run git status at every step, as listed. Watching the same files move from untracked to staged to committed is what makes the three states stick.

Check your understanding

Answered 0/3
Mode:

What does `git init` do?

Why is there a separate `git add` step before `git commit`?

You run `git status` and see files under "Untracked files". What does that mean?

Finish the task in the terminal and answer the questions to complete the lesson.

📝 My notes

Saved automatically in this browser · shows up on the Notes page.

Task

Turn this folder into a repository and make your first commit.

Tab complete · history · Ctrl+L clear · help commands

  • Not done: Start tracking this folder
  • Not done: Stage the files
  • Not done: Commit with a message
  • Not done: git status confirms everything is saved

Lesson Q&A

What does `git init` do?

It creates a hidden .git folder where the history is stored. Everything stays on your machine.

Why is there a separate `git add` step before `git commit`?

Staging lets one commit be one coherent change, even when you have edited several unrelated things.

You run `git status` and see files under "Untracked files". What does that mean?

Untracked means git knows the file exists but has never been told to look after it. git add changes that.

After git init, where does your project live?

init is local and offline. It creates a .git folder next to your files and changes nothing else.

Which git command is safe to run at literally any time?

status is a read. It is the one command you cannot use wrongly.

You fixed a bug and also renamed some variables. How do you record just the bug fix?

That separation is the entire reason staging exists. One commit, one coherent change.

What does 'nothing to commit, working tree clean' mean?

Clean means the files on disk are identical to the last commit. Nothing would be lost right now.

Move between lessons with · search with ⌘K