What is the staging area in Git? (git add explained)

The staging area is what goes into your next commit. You edit files, git add the changes you want, then git commit saves exactly what's staged. It lets you commit some changes and keep others for later.

Step by step

  1. See what changed and what's staged:

    $ git status
  2. Stage one file:

    $ git add menu.js
  3. Or stage everything:

    $ git add .
  4. Commit what's staged:

    $ git commit -m "Add mocha to the menu"
  5. Unstage a file (keep your edits):

    $ git restore --staged menu.js

git diff shows changes that aren't staged yet; git diff --staged shows what will be committed.

Try it in the interactive sandbox →Practice “Stage it” with a real repository and teammates, right in your browser.

Related guides