How to Stage Changes in Git (git add)

git add moves changes from your working directory into the staging area, marking them to be included in the next commit.

Published September 27, 2026

git add moves changes from your working directory into the staging area (index), choosing exactly what goes into the next commit.

How it works

Git has three areas: working tree, staging area and repository. Staging lets you build a clean, focused commit even if you changed many things.

git add -p lets you stage individual hunks within a file.

Try it

git status
modified: app.js (not staged)
git add app.js
git status
Changes to be committed: modified: app.js

Practical examples

Stage a file or folder

git add src/app.js
git add src/

Stage everything

git add -A

Stage interactively by hunk

git add -p

Unstage

git restore --staged app.js

Common mistakes

  • Using git add . and committing secrets or build output.
  • Forgetting new files are untracked until added.
  • Not reviewing with git diff --staged.

Key takeaways

  • Staging picks what the commit contains.
  • git add -p for partial commits.
  • Review with git diff --staged.

FAQ

git add . vs -A?

In modern Git they behave the same in the current tree; -A covers the whole repo.

How do I unstage?

git restore --staged <file>.

More Git articles