Git Add -A vs -u: Stage Multiple File Changes
Update only tracked paths
In the bulk fixture, notes.txt is modified, obsolete.txt was deleted on disk, and todo.txt is new. git add -u updates existing index entries: modifications and deletions, not new untracked paths. Without a pathspec, it acts across the working tree on modern Git.
git status --shortgit add -ugit diff --cached --name-statusgit status --shortThe staged list has M notes.txt and D obsolete.txt. The new todo.txt still shows ?? in status. The next commit would omit the new file.
Include new files as well
git add -A synchronizes the index with additions, modifications and removals in scope, respecting ordinary ignore rules for untracked paths. A pathspec limits that scope. Preview a broad operation and inspect the staged diff instead of assuming every changed file belongs together.
The preview does not stage todo.txt. After the real command the staged list also contains A todo.txt. git add -A -- notes.txt would limit the operation to notes.txt; git add . limits scope to the current directory and descendants.
Practice and check before committing
Predict which paths would be staged if a new file were ignored by an existing rule. Then inspect git diff --cached and explain why a new untracked file is missing after -u. Do not stage credentials or unrelated output merely because a broad command is convenient.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Git Add -A vs -u: Stage Multiple File Changes — knowledge check
Apply the file management and ignore rules taught in this lesson.
Which changes does git add -u stage?
After git add -u, what status can a new untracked todo.txt show?
Which command includes new unignored files as well as tracked edits and deletions?
How can you restrict a broad add to notes.txt?
What should you inspect before committing a broad stage operation?