What is the Staging Environment?

The staging area is where Git prepares files before committing them. It lets you review and organize changes before creating a commit.

Three Stages in Git

  1. Working Directory: Your actual project files where changes are made.
  2. Staging Area (Index): Where changes are reviewed before committing.
  3. Repository: Where committed changes are permanently saved.

Add to Staging

git add filename.txt

This adds the file to the staging area.

View Staged Files

git status

Shows staged (green) and unstaged (red) files.

Commit Staged Files

git commit -m "Commit message"

This saves all staged changes to the repository.

Skip Staging (Quick Commit)

git commit -a -m "message"

This command automatically stages and commits tracked file changes (not new untracked files).