Loading lessons...
Adding New Files
Adding New Files
When you create a new file in a Git repository, Git does not track it until you tell it to.
The add command
Use git add to start tracking a file:
git add index.html
To add a whole folder:
git add images/
To add everything at once:
git add .
Check what Git sees
git status
Before adding, new files show up as untracked. After git add, they move to the staging area and show as "new file" changes ready to commit.
Tracked vs untracked
- Untracked: Git never saw this file before.
- Tracked: Git watches this file and knows its history.
- Staged: the file is ready to be committed.
Example
git status
git add index.html
git status
The first git status shows your file as untracked. After git add, the same file appears as a staged change.
TL;DR
git add filestarts tracking a file.git add .adds all changes.- Untracked files become tracked once you add them.
- Added files sit in the staging area, ready to commit.