Skip to content
Latchkey

git add: Usage, Options & Common CI Errors

git add moves changes from your working tree into the staging area (the index).

Staging is how you choose exactly what goes into the next commit. The flags control scope; pathspecs control precision.

What it does

git add records the current content of files into the index so they will be part of the next commit. It does not commit anything by itself.

Common usage

Terminal
git add file.txt
git add .            # everything under the current directory
git add -A           # all changes incl. deletions, whole tree
git add -u           # only already-tracked files
git add -p           # interactively stage hunks

Options

FlagWhat it does
-A / --allStage adds, modifications, and deletions everywhere
-u / --updateStage changes to tracked files only
-p / --patchChoose hunks interactively
-f / --forceAdd files that .gitignore would skip
-n / --dry-runShow what would be added

Common errors in CI

fatal: pathspec 'X' did not match any files - the path does not exist or is ignored. Check the working directory and whether .gitignore excludes it; use git add -f to override an ignore, or git status to see the real paths.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →