Move work from the working tree into the index.
Move changes from the working tree into the index (the staging area), preparing them for the next commit. You stage what you intend to commit; everything else stays unstaged.
The index is a binary file at .git/index. Each git add writes the file's current content into a blob in the object DB and points the index entry at it. The blob is permanent the moment you stage; even if you re-edit and never commit, the blob still exists until garbage collection.
git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i]
[--patch | -p] [--edit | -e] [--[no-]all | -A | --no-ignore-removal]
[--update | -u] [--intent-to-add | -N] [--refresh] [--ignore-errors]
[--ignore-missing] [--renormalize] [--chmod=(+|-)x]
[--pathspec-from-file=<file> [--pathspec-file-nul]]
[--] [<pathspec>...]| Flag | What it does |
|---|---|
-A, --all | Stage everything — additions, modifications, deletions — across the whole tree. |
-u, --update | Stage modifications and deletions of already-tracked files. Doesn't add new files. |
-p, --patch | Interactively pick hunks to stage. The single most underused power in Git. |
-i, --interactive | Full interactive menu. Use -p for the most useful sub-mode. |
-n, --dry-run | Show what would happen, don't change anything. |
--intent-to-add, -N | Tell the index a path will exist; useful for rename detection on git diff before staging. |
--renormalize | Re-stage with current line-ending/eol attributes. Use after changing .gitattributes. |
--force, -f | Stage a file that's normally ignored by .gitignore. You probably mean it; double-check. |
git add path/to/file.git add ..git add -u.git add -p.$ git add src/main.c$ git add .$ git add -p src/main.c$ git add --renormalize .git add -p. It changes how you commit: small, single-purpose commits become easy.git add . is fine when you intend everything in the dir. git add -A from any subdir stages the whole tree — riskier if you have unrelated changes elsewhere.git add + git status constantly. Status tells you what staged, add changes it.reset and don't commit, the blob is reachable until GC. Treat add of secrets as a leak.git add . doesn't pick up deletions of files you removed via rm. Use -A or -u for that.git add after editing is the #1 source of 'why didn't my change land?' confusion.Hit each option, then Check answers. Score is recorded; Next is always open.