What is the staging area in Git?

The staging area, also called the index, is a waiting room between your working directory and the repository. You put changes in it with git add, and git commit saves only what is staged.

It is useful because you can choose exactly what goes into a commit. If you changed five files but only two are for one fix, stage those two, commit them, and leave the rest for another commit.

Terminal output

$ git add a.txt
$ git status -s
A a.txt
?? b.txt

Here A means a.txt is staged, and ?? means b.txt is not. See Git Workflow.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.