Skip to content
rajin

02Your first repository and commit

foundation25–30 minHandbook pp. 9–10 Not started

Warm-up · from “Why version control exists”

Does saving a file create a commit?

No notes: write what you remember, then check. Recalling before reading is what makes it stick.

The problem

A teammate asks you to send only your finished changes, not your experimental notes. How do you decide what Git saves?

After this lesson you can

  • Initialize a repository.

  • Stage one file.

  • Distinguish tracked, untracked and committed files.

Key terms

Full glossary

Say what each term means, then open it to check.

  • Tree · preview, covered in lesson 6

    Directory snapshot mapping names, modes and object IDs.

  • Commit · preview, covered in lesson 7

    Object identifying a root tree, parent(s), metadata and message.

Visual mental model

  1. Working files
  2. Indexgit add
  3. Historygit commit

Build the mental model

A repository consists of a working tree and Git metadata. The working tree is your editable project. The metadata includes objects, references and the Index. git init creates this structure. git status reports the relationship among files on disk, staged content and the current commit. Before the first commit, the branch is unborn: HEAD names a branch that has no commit yet.

Under the hood

The normal loop is edit, inspect, stage, inspect again, commit. A file can be untracked, tracked and modified, or staged. A tracked file may also contain unstaged edits. git log shows committed history, not all edits. Use meaningful commit messages describing the purpose of a change, not simply the filename.

Common mistake · important nuance

Do not run git add . blindly in a real project; secrets, generated files and unrelated changes may be included. Use .gitignore for intentionally untracked files; it does not untrack an already tracked file.

Move between parts freely. Completion counts only what you verify and answer.