Git: getting started

Lesson 01 · 10 min

Repository, add, commit

Git remembers snapshots of a folder. add selects, commit records. It's not "save the file".

git init in the project folder creates a hidden .git directory: that's where the history lives. Your working files stay as they were. git status shows what Git sees: new, modified, already staged. Until you add and commit, the history is empty — even if the code is already written.

The first snapshot
AI

You can ask about this rule«The index is neither the disk nor the history»

  • A commit message says what changed and why, not "fix" ten times in a row.
  • .gitignore is what never gets committed: node_modules, .env, the build.
  • git diff — not staged yet. git diff --staged — already added, not committed yet.
AI

You can ask about this point«Lesson summary»

Check

Lock it in before you move on

  1. 1. What does git init do?

  2. 2. git add file does

  3. 3. You saved a file in the editor. Did Git see it as a commit?

PracticeSolve the lesson tasksA few short tasks in the editor. Check your code right away and see where it goes wrong.Start practice