Staging Area
What
The Staging Area (also referred to as the “Index”) is a preparation zone where Git gathers changes before they are officially committed to the repository’s history.
How
To move a file from an untracked or modified state into the staging area, use the git add command:
# Stage a specific file
git add <path_to_file>
# Stage all files and modifications in the current directory and its subdirectories
git add .
After running git add, running git status will show the staged files under “Changes to be committed”.
Why
The staging area is one of Git’s most powerful features because it allows you to craft precise, clean commits. If you make five unrelated changes across three files, you don’t have to save them all at once. You can stage only the files (or even specific lines of code) that relate to a single topic, commit them with a focused message, and then stage the remaining changes separately.
Summary
Use git add to stage specific files and prepare them to be captured in your next database commit.