โ† Git Essentials

Repositories and Commits

~280 words ยท 2 min read

What is a Git repository?

A repository (or "repo") is Git's name for a folder that tracks history. When you run git init inside a directory, Git creates a hidden .git subfolder that stores every snapshot you ever take. The repository is that history โ€” your working files are just the current view.

The three areas

  • Working directory โ€” the files you see and edit.
  • Staging area (the "index") โ€” changes you've marked as ready to commit.
  • Repository (.git/) โ€” the permanent history of commits.

Making a commit

A commit is a snapshot. You create one in two steps:

git add .          # stage all changes
git commit -m "Add login page"

Each commit gets a unique 40-character hash (SHA-1). That hash is the identity of the snapshot โ€” Git never rewrites commits, it only creates new ones.

Think of commits as save-points in a game. You can always go back to any one of them.

Viewing history

git log --oneline --graph

This shows a compact one-line-per-commit view with a branch graph โ€” the command you'll use most often to orient yourself.