TutorialsGitThe Core Workflow
Git

The Core Workflow

Every change in Git moves through three areas: the working directory (your files), the staging area (what's queued for the next commit), and the repository (committed history).

Working Directory  →  Staging Area  →  Repository
     (edit)         (git add)        (git commit)

The basic cycle

# 1. Make changes to files, then check what changed
git status

# 2. Stage the changes you want to commit
git add file.js          # a specific file
git add .                 # everything in the current directory

# 3. Commit the staged changes with a message
git commit -m "Add login form validation"
💡

A commit is a snapshot of your staged changes plus a message. Write clear, present-tense messages: "Add X", "Fix Y", "Refactor Z".

Viewing changes

git diff           # unstaged changes vs last commit
git diff --staged  # staged changes vs last commit
git log            # commit history
git log --oneline  # compact one-line-per-commit view

Undoing changes

# Discard unstaged changes to a file (careful — irreversible)
git restore file.js

# Unstage a file (keep the changes)
git restore --staged file.js

# Change the last commit's message (before pushing)
git commit --amend -m "Better message"

A good commit habit

Commit small, logical units of work — each commit should represent one coherent change. This makes history easy to read, review, and revert.

git add src/auth.js
git commit -m "Add password hashing to auth"

git add src/api.js
git commit -m "Add rate limiting to API routes"

Watch & Learn

A recommended video to watch alongside this chapter.

More “The Core Workflow” videos on YouTube