LESSON 5

Commits

Learning objective: Save snapshots of your work with commits.

Understand

A commit is a saved snapshot of your project.

You add files to the staging area, then commit them with a message describing the change. Good, small commits with clear messages make history easy to read and undo.

Analogy: A commit is a save point in a game, with a note about what you just did.

See It in Action

Staging and committing:

git add .
git commit -m "Add homepage"
How it works: git add . stages your changes and git commit -m records them with a short, descriptive message.

Try It Yourself

  1. Create or edit a file.
  2. Stage it with git add.
  3. Commit it with a clear message.

Quick Quiz

What is a commit?

Challenge

Make two commits with clear, descriptive messages.

Success condition: Your repository history shows two well-described commits.