Git add . vs git add -A: Key Differences and When to Use Each
git add . command stages new and modified files in the current directory and its subdirectories but ignores deleted files. In contrast, git add -A stages all changes including new, modified, and deleted files across the entire repository.Quick Comparison
Here is a quick side-by-side comparison of git add . and git add -A to highlight their key differences.
| Feature | git add . | git add -A |
|---|---|---|
| Scope of files | Current directory and subdirectories | Entire repository |
| Includes deleted files | No | Yes |
| Includes new files | Yes | Yes |
| Includes modified files | Yes | Yes |
| Common use case | Add new and changed files locally | Add all changes including deletions globally |
Key Differences
git add . stages all new and modified files only within the current directory and its subdirectories. It does not stage file deletions, so if you removed files, those deletions will not be included in the next commit.
On the other hand, git add -A stages all changes across the entire repository, including new files, modifications, and deletions. This means it tracks removed files and prepares them for commit, which git add . does not do.
Another difference is the scope: git add . works relative to your current folder, while git add -A affects the whole project regardless of your location in the directory tree.
git add . Code Example
git add .
git add -A Equivalent
git add -A
When to Use Which
Choose git add . when you want to quickly stage new and modified files only in your current working folder without affecting deletions or files outside this folder.
Choose git add -A when you want to stage every change in your entire project, including file deletions, ensuring your commit fully reflects all modifications.
For most complete commits, git add -A is safer to avoid accidentally missing deleted files.
Key Takeaways
git add . stages new and modified files only in the current directory and ignores deletions.git add -A stages all changes including deletions across the entire repository.git add -A to ensure all changes are included in your commit.git add . for quick staging limited to your current folder.