HOWTO · Git
How to Stage All Changes in Git
Learn how git add -A, git add ., and git add -u stage new, modified, and deleted files, then review or adjust the index before committing.
On this page
Git stages changes in the index (also called the staging area), which holds the content prepared for the next commit. Staging does not create a commit: it lets you choose and review that snapshot first. To stage every change in a working tree, use git add -A from the repository root, then inspect the index before committing.
What “add all” means in Git
“All” refers to the changes in the scope you give Git, not every file on your computer. A change can be a new file, an edit to a tracked file, or a deletion. The index records the versions and removals that the next commit will contain. Files matched by ignore rules are generally excluded from ordinary adds; check your ignore rules if an expected untracked file does not appear.
Choose the right git add form
| Command | New files | Modified tracked files | Deleted tracked files | Scope |
|---|---|---|---|---|
git add -A or git add --all |
Yes | Yes | Yes | Entire working tree when no path is given; otherwise the supplied pathspec |
git add . |
Yes | Yes | Yes | Current directory and its descendants |
git add -u |
No | Yes | Yes | Tracked files in the working tree, or the supplied pathspec |
The long option is git add --all; git add -all is not its equivalent. With no pathspec, git add -A stages changes throughout the working tree. git add . is useful when you mean only the current directory tree. From a subdirectory, its scope does not include sibling directories or parent-level paths. git add -u updates tracked paths and does not add new files. A pathspec further limits each command, so quote patterns when you want Git, rather than the shell, to interpret them.
Stage all changes with git add -A
Run the command from the repository root when the goal is to stage all non-ignored additions, edits, and deletions in the working tree:
set -eu
repo=$(mktemp -d)
trap 'rm -rf "$repo"' EXIT
git -C "$repo" init -q
git -C "$repo" config user.name Example
git -C "$repo" config user.email example@example.invalid
printf 'before\n' > "$repo/changed.txt"
printf 'keep\n' > "$repo/removed.txt"
git -C "$repo" add changed.txt removed.txt
git -C "$repo" commit -qm initial
printf 'after\n' > "$repo/changed.txt"
rm "$repo/removed.txt"
printf 'new file\n' > "$repo/new.txt"
git -C "$repo" add -A
git -C "$repo" status --short --untracked-files=all
This example creates a temporary repository, changes one tracked file, deletes another, and adds a new file before staging. The final status lists the staged paths and their status letters. The two columns in short status represent the index and working tree; a letter in the left column indicates a staged change. The example is self-contained and removes its temporary files when it finishes.
If you want only one subtree, pass that path explicitly, for example git add -A -- src/. Git then stages matching additions, modifications, and removals within that pathspec. Review the scope before committing, especially when running a command from a subdirectory or using a broad pathspec.
Review and adjust the staged changes
Use git status to see which paths are staged and which still have unstaged edits. Inspect the staged patch with git diff --cached; git diff --cached --stat gives a compact summary. Review the patch itself, since a path appearing as staged does not tell you whether its content belongs in the commit.
To remove a path from the index while keeping its working-tree content, run git reset -- path/to/file. This changes what is staged; it does not discard the file’s edits. You can then stage the corrected version or a narrower set of changes and inspect the index again.
Stage selected files or parts instead
When you do not intend to include every change, name the files: git add README.md, or list several paths such as git add src/app.py tests/test_app.py. To choose portions of tracked-file edits interactively, run git add -p and select the hunks to stage. These commands provide narrower control; they do not stage every change in the working tree. Finish by checking git status and git diff --cached so the next commit contains the changes you intended.