Skip to main content

Sign in

Save your progress and access it from any device.

Or with email

Don't have an account?

Privacy policy

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.

Fundamental

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 Directory

Your local files, modified or new

git add
Staging Area (Index)

Files ready to be committed

git commit
History

Commits 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 file

Stage a specific file

git add .

Stage the entire current directory

git add -A

Stage everything (including deletions)

git add -p

Interactive patch-by-patch mode

git add *.ext

Stage by pattern (glob)

git add -u

Stage 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

A

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