#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:
$ 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:
$ git add index.html # Add a specific file
$ git add . # Add all modified filesgit 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:
$ 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:
$ git log
commit a1b2c3d (HEAD -> main)
Author: Alice <alice@email.com>
Date: Mon Mar 3 10:00:00 2026
Initial commitFor a more compact view, use the --oneline option:
$ git log --oneline
a1b2c3d (HEAD -> main) Initial commitSummary
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 historyYour turn
Practice the git add / git commit cycle in the terminal below. Start with git status to see the project state.