How to add files to Git staging area

· Category: Git

Short answer

Use git add <file> to stage specific files or git add . to stage all changes in the current directory.

Steps

  1. Stage a single file:
git add filename.txt
  1. Stage all changes:
git add .
  1. Stage only modified files (not new untracked files):
git add -u
  1. Interactively stage changes:
git add -p

Tips

  • Use git add -p to review each chunk of changes before staging.
  • git add -A stages all changes including deletions across the entire repository.
  • Staging allows you to craft clean, logical commits rather than dumping all changes at once.

Common issues

  • Accidentally staging files: use git reset HEAD <file> to unstage.
  • Large binary files: consider using Git LFS to avoid bloating the repository.