Git Reference
Git Reference / Mental model

01Mental model

Git stores snapshots, not diffs. Every commit is a full picture of your project, identified by a hash, pointing back to its parent(s). Branches are just movable labels on commits.

Working directory files you edit Staging area “index” — next commit Repository .git — commit history git add git commit git restore --staged git restore git switch / git checkout

Commit

An immutable snapshot plus metadata (author, message, parent hashes). Identified by a SHA like a1b2c3d.

Branch

A lightweight pointer to a commit. Committing moves the current branch forward automatically.

HEAD

“Where you are now.” Usually points to a branch; if it points straight at a commit, you’re in detached HEAD.

Remote

Another copy of the repo (e.g. on GitHub). origin/main is your local memory of where main is on origin.