Git add: stage files for your next commit
Before committing, you need to tell Git which files to include. git add places your changes in the staging area, ready for the next commit.
What is git add?
git add is the bridge between your working directory and the next commit. It places changes in the staging area (also called the index).
Think of it like shopping: you put items in your cart (git add) before checking out (git commit). You can add or remove items as many times as you want before confirming.
Without git add, your changes will not be included in the next commit. It's the most fundamental command after git init.
The Git workflow in 3 steps
Working DirectoryYour local files, modified or new
git addStaging Area (Index)Files ready to be committed
git commitHistoryCommits permanently recorded
Git add in practice
Add specific files or the entire directory.
Add specific files
Add all or by pattern
Essential add commands
git add fileStage a specific file
git add .Stage the entire current directory
git add -AStage everything (including deletions)
git add -pInteractive patch-by-patch mode
git add *.extStage by pattern (glob)
git add -uStage tracked modified files
Common mistakes with git add
git add . without a .gitignore
You risk adding node_modules, .env, build files... Always create a .gitignore before your first git add.
Forgetting git add before git commit
If you commit without add, nothing happens. Git only commits what is in the staging area.
Confusing add and commit
git add does not save anything to the history. It's git commit that creates the permanent snapshot.
Part of the Git Basics guide
GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.
Questions about git add
Master staging with GitQuest
Learn to prepare your commits like a pro with GitQuest's interactive challenges.
Get started now