Phase 3Local Git

#10 The add/commit cycle

git add, commit, log

The 3 zones of Git

Git organizes your work into three distinct zones:

  • Working Directory: your files as you see and edit them.
  • Staging Area: the changes you have selected for the next save.
  • Repository: the history of all saved versions.

The workflow is always the same: you modify files, add them to the staging area with git add, then save them with git commit.

git status -- See the project state

The git status command shows which files have been modified, added, or are ready to be saved:

Check the state
$ git status
On branch main

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	index.html
	style.css

nothing added to commit but untracked files present (use "git add" to track)

Here, Git tells us that two files are not yet tracked (untracked).

git add -- Add to the staging area

You select the files to include in the next commit with git add:

Add files
$ git add index.html       # Add a specific file
$ git add .                # Add all modified files

git add . adds all modified files in the current directory. It's convenient but be careful not to add unwanted files!

git commit -- Save changes

Once files are in the staging area, you create a commit (a save point) with a message describing the changes:

Create a commit
$ git commit -m "Initial commit"
[main (root-commit) a1b2c3d] Initial commit
 2 files changed, 42 insertions(+)

The message in quotes is mandatory. It should be clear and describe what was done. Each commit receives a unique identifier (here a1b2c3d).

git log -- View history

To view the commit history:

Commit history
$ git log
commit a1b2c3d (HEAD -> main)
Author: Alice <alice@email.com>
Date:   Mon Mar 3 10:00:00 2026

    Initial commit

For a more compact view, use the --oneline option:

Compact history
$ git log --oneline
a1b2c3d (HEAD -> main) Initial commit

Summary

Summary
git status                    # See the project state
git add file.txt              # Add a file to staging
git add .                     # Add all files
git commit -m "message"       # Save changes
git log                       # View history
git log --oneline             # Compact history

Your turn

Practice the git add / git commit cycle in the terminal below. Start with git status to see the project state.

terminal — bash
user@stemlegacy:~/my-project$