Progress:
TIER 1 · MODULE 04· Basics

git add

Move work from the working tree into the index.

🎯 What & why

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.

🧠 Mental model

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.

🛠️ Synopsis

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>...]

🎚️ Switches & options

FlagWhat it does
-A, --allStage everything — additions, modifications, deletions — across the whole tree.
-u, --updateStage modifications and deletions of already-tracked files. Doesn't add new files.
-p, --patchInteractively pick hunks to stage. The single most underused power in Git.
-i, --interactiveFull interactive menu. Use -p for the most useful sub-mode.
-n, --dry-runShow what would happen, don't change anything.
--intent-to-add, -NTell the index a path will exist; useful for rename detection on git diff before staging.
--renormalizeRe-stage with current line-ending/eol attributes. Use after changing .gitattributes.
--force, -fStage a file that's normally ignored by .gitignore. You probably mean it; double-check.

💡 Use cases

🧪 Examples

Stage a single file by path.
$ git add src/main.c
Stage all changes in the current dir and below (ignoring .gitignore).
$ git add .
Stage selectively — interactive hunk picker. Quit with q.
$ git add -p src/main.c
Stage line-ending re-normalization after editing .gitattributes.
$ git add --renormalize .

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.