Skip to main content
Working with Changes

git add

Stage changes — prepare them for the next commit

Practical Example

git add src/index.ts          # stage a single file
git add -p                   # stage interactively, hunk by hunk
git add .                    # stage all changes in current dir

Command Overview & How It Works

Moves changes from the working directory into the staging area (also called the index). Only changes that have been staged will be included in the next git commit. Use git add <file> to stage a single file, git add . to stage all changes in the current directory (including new files), or git add -p to stage interactively — this shows each hunk of changes and lets you decide whether to stage it, a powerful way to create clean, focused commits. Use git add -A to stage all changes across the entire repository (not just the current directory). Staging is what makes Git different from older version control systems — it gives you fine-grained control over what goes into each commit without needing to commit everything at once.

Practical Tips

  • Use git add -p to review each hunk interactively and build clean, focused commits.
  • Use git add -A to stage deletions across the whole repository, not just new and modified files in the current directory.
  • Review what is staged with git diff --staged before you commit.

Related Commands in Working with Changes