git add
The "add" command marks changes to be included in the next commit.
It adds changes to Git's "Staging Area", the contents of which can then be wrapped up in a new revision with the "git commit" command.
Important Options
<file-path>
Specifies the files you want to add to the Staging Area. Note that you can both enter multiple file paths as well as paths to directories (the latter will then add all modifications in this directory to the Staging Area).
--all
Adds all modifications to the Staging Area. This includes changed files, deleted files, and new files - anywhere inside the project directory.
-u
Adds all changes to existing files to the Staging Area. This includes changed files and deleted files - but not new files that aren't currently tracked by Git.
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
Usage Examples
You can provide one or multiple paths and thereby add changes in these files to the Staging Area:
git add index.html error.html
These changes will then be part of the next commit.
In case you want all current modifications in your project to be added to the Staging Area (including deletions and new files), you can simply use "--all" or "-A":
git add --all
Tip
Staging Chunks or Lines of Your Changes
Using the Tower Git client, you can easily select the exact chunks & lines you want to add to the next commit.
Try it free for 30 days and see why 100,000 developers all over the world use Tower to be more productive with Git!
Learn More
- Check out the chapter Working on Your Project in our free online book
- Find the full command description in the Git documentation
- More frequently asked questions about Git & version control