Back to roadmap

Lesson 04

Commits

A commit saves the staged version of your files as a checkpoint on your current local branch.

Visual Explanation

Ready to run git commit -m "Add navigation".

Keep These Ideas

Staged snapshot
The commit records the staged snapshot; unstaged changes are excluded.
Commit
A saved checkpoint on the current local branch. It is not pushed automatically.
Message
A short explanation of why this checkpoint matters.

The Real Command

Terminal
git commit -m "Add navigation"

git commit saves the staged snapshot on the current local branch. In this example, that branch is feature/login. The -m flag attaches a short message.

Command Details

git commit --dry-run

--dry-run previews the commit. It shows what would be included without saving anything.

Example Output
On branch feature/login
Changes to be committed:
  modified:   app.js
git commit --amend --no-edit

--amend replaces the latest local commit. --no-edit keeps its message. Avoid amending a commit teammates already use.

Knowledge Check

Save a Clear Checkpoint

Turn staged work into a focused checkpoint with a useful message.

Question 1 of 5

  1. Question 1: current
  2. Question 2: not started
  3. Question 3: not started
  4. Question 4: not started
  5. Question 5: not started
Command Challenge

Your navigation changes are staged. Type the command that saves them with the message Add navigation.