Skip to the workspace
Pebellslearn by building
What is a Repository  ›  Lesson

Committing Changes

Committing Changes 12 minA commit is a snapshot of the staged files with author, time, message and a link to its parent, and each commit should hold one idea with a clear message.

git github / Committing Changes

Explore each scene at your own pace.

01 · The rule

The rule

Committing Changes

A commit is the snapshot that actually lands in history. Asha will read her commits months from now, so each one should be a single, clear step: one idea, one message.

The rule

One commit, one idea, with a message that finishes "This commit will…".

After staging, record the snapshot:

git add pancakes.md
git commit -m "Add baking powder amount to pancakes"

Each commit stores:

  • a snapshot of every tracked file as it was staged,
  • the author (from user.name and user.email) and the time,
  • the message,
  • a link to its parent commit, the one before it. That link is what turns separate snapshots into a history.

Git gives every commit a unique ID, a long hash such as 4f9c2e1…. The first seven or so characters are usually enough to name it.

Good messages are short, specific and written as a command: "Add chai recipe", "Fix oven temperature in bread", "Remove duplicate salt line". A handy test: the message should complete the sentence "If applied, this commit will…". Messages like "stuff", "fix" or "changes" tell future readers nothing.

Keep commits focused. If you fixed a typo and also rewrote a recipe, stage and commit them separately. A focused commit is easy to understand, easy to review and easy to undo on its own.

Two handy variations:

git commit                  # opens your editor for a longer message
git commit -am "Tweak chai sugar"   # stages every modified tracked file, then commits

-a only includes files Git already tracks. A brand-new, untracked file still needs git add first.

If you run git commit with nothing staged, Git reports that there is nothing to commit and makes no snapshot.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.