Git & GitHub Interview Question #13

What is the difference between git add . and git add -A?

Git Fundamentals, Repository, Working Tree, Staging, Commits & Branch Basics Junior Beginner

Quick Interview Answer

Both commands often stage a broad set of changes, but their path scope can matter depending on where the command is run and the Git version. git add -A explicitly stages additions, modifications, and deletions across the repository, while git add . uses the current pathspec and stages relevant changes under the current directory.

Detailed Explanation

Both commands often stage a broad set of changes, but their path scope can matter depending on where the command is run and the Git version. git add -A explicitly stages additions, modifications, and deletions across the repository, while git add . uses the current pathspec and stages relevant changes under the current directory.

In practice, developers should inspect git status after staging instead of relying on memory about broad commands.

Code Example

git add -A
git status

# or from the intended directory
git add .
git status