git add . stages all changes in the current directory and everything below it — modified files, new files, and deleted files — in a single command. It’s the fastest way to prepare everything for a commit when you want the full working-directory state captured. This is the fourth post in this site’s Git command guide, following Git Add.
Basic Usage
Suppose you made changes to two files named file1.txt and file2.txt and you want to include both in your next commit. Navigate to the project directory in the terminal and execute:
git add .
This stages all changes in the repository. You can now review what’s staged by running:
git status
You should see that both file1.txt and file2.txt have been staged. Now commit the staged changes:
git commit -m "Added new feature to file1.txt"
The commit will include all changes.
git add . vs git add -A
In modern Git (2.x), git add . and git add -A behave identically when run from the root of the repository — both stage new files, modifications, and deletions across the entire working tree. The difference only matters if you run the command from a subdirectory: git add . stages changes relative to the current directory, while git add -A always stages the entire repository regardless of where you are.
When to Use git add . vs git add <file>
- Use
git add .when all your current changes belong together in one logical commit and you’re confident nothing is modified that shouldn’t be. - Use
git add <file>(covered in Git Add) when you want to stage only a subset of your changes and leave others for a separate commit. - Always run
git statusbefore committing to confirm exactly what was staged — especially withgit add ., which is easy to overuse.
See Also: This Site’s Git Command Guide
This post is part of a 13-part Git command guide on this site:
- Git Init — starting a brand-new repository
- Git Clone — copying an existing repository
- Git Add — staging specific files for a commit
- Git Commit — saving staged changes to the repository
- Git Status — checking what’s changed before you commit
- Git Branch — creating, listing, and renaming branches
- Git Checkout — switching branches and restoring files
- Git Push — sending your commits to a remote
- Git Pull — fetching and merging remote changes
- Git Log — reading commit history
- Git: Delete Last Commit — undoing a commit safely
- Git – Autocorrect Spelling — typo recovery and productivity config
Conclusion
git add . is the fastest path from working changes to a staged snapshot, but it’s most useful when you’ve kept your changes focused. Once everything is staged, the next step is locking them in — covered in Git Commit.