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
See what changed and what's staged:
$ git statusStage one file:
$ git add menu.jsOr stage everything:
$ git add .Commit what's staged:
$ git commit -m "Add mocha to the menu"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.