TracksPractical Coding FoundationsVersion ControlStaging Changes(4 of 12)

Staging Changes

Staging is how you tell Git which changes to include in your next commit. Instead of automatically saving everything, Git lets you choose specific files or even specific lines. This gives you control over what each commit contains.

Why Staging Exists

Imagine you fixed a bug and also reformatted some unrelated code. With staging, you can commit the bug fix separately from the formatting changes. This keeps your project history clean and makes it easier to understand what each commit does.

The staging area — sometimes called the "index" — is like a preview of your next commit. You add changes to it, review what's there, then commit when you're ready.

Staging Files

Use git add followed by the filename to stage a specific file:

The file moves from "untracked" or "modified" to "staged." It's now queued for the next commit.

Staging Multiple Files

You can stage several files at once by listing them:

git add hello.py utils.py readme.md

Or stage everything that's changed with a dot:

The dot means "current directory and everything in it." This stages all modified and untracked files. It's convenient but use it thoughtfully — make sure you actually want to commit everything.

Checking What's Staged

Always run git status after staging to verify you've selected the right files. The "Changes to be committed" section shows what's staged. The "Changes not staged for commit" section shows modifications you haven't staged yet.

Unstaging Files

Changed your mind? Remove a file from the staging area without losing your changes:

The file returns to "modified" or "untracked" status. Your actual changes in the file remain intact — you're just removing it from the commit preview.

The Staging Workflow

A typical workflow looks like this:

  1. Make changes to files
  2. Run git status to see what changed
  3. Stage the files you want: git add filename
  4. Run git status again to verify
  5. Commit when ready

This deliberate process helps you create meaningful commits that tell a clear story.

See More

Further Reading

Last updated December 6, 2025

You need to be signed in to leave a comment and join the discussion