git-add
Stage changes for commit
TLDR
Add a file to the index
Add all files (tracked and untracked)
Add all files recursively starting from the current folder
Only add already tracked files
Also add ignored files
Interactively stage parts of files
Interactively stage parts of a given file
Interactively stage a file
SYNOPSIS
git add [options] [--] [pathspec]…
PARAMETERS
-A, --all
Stage all changes: new, modified, deleted files everywhere.
-u, --update
Stage modified/deleted files only, not new files.
-p, --patch, --interactive
Interactively select hunks to stage.
-e, --edit
Edit patches in editor before staging.
-N, --intent-to-add
Stage file as intent-to-add without content.
--refresh
Update index from working tree without staging.
--ignore-errors
Continue on unreadable files.
--ignore-missing
Ignore pathspecs that do not exist.
-i, --interactive
Run interactive prompt for staging.
--dry-run
Show what would be staged without doing it.
-f, --force
Allow adding ignored files.
--renormalize
Renormalize stored line endings.
--chmod=(+|-)x
Override executable bit.
--pathspec-from-file=<file>
Read pathspecs from file.
--pathspec-file-nul
Use NUL-terminated paths in file.
DESCRIPTION
The git add command adds file contents to the Git index (staging area), preparing them for the next git commit. It moves changes from the working directory into the index without committing them. By default, it stages entire files specified by pathspecs.
Use git add <file> for specific files, git add . for the current directory recursively, or git add -A to stage all changes repository-wide, including new files, modifications, and deletions.
Options enable selective staging: -u for updates (modified/deleted files only), -p for interactive hunk-by-hunk selection, and -N to mark files for future addition without staging content. It supports sparse-checkout and handles submodules.
Common workflow: edit files, run git add, then git commit. Always verify with git status or git diff --cached. Interactive modes (-i or -p) are powerful for partial commits.
CAVEATS
Does not commit changes—only stages them. -A stages everything; use cautiously in large repos. Ignores files in .gitignore by default unless -f. Submodule changes require separate handling.
COMMON EXAMPLES
git add file.txt
git add . (current dir)
git add -A (all changes)
git add -p (interactive)
VERIFICATION
Use git status or git diff --cached to review staged changes before commit.
HISTORY
Introduced in Git 1.0.0 (April 2005) by Linus Torvalds as core staging command. Evolved with interactive features in Git 1.5 (2007) and sparse-checkout support in Git 1.7 (2010). Remains fundamental in modern Git workflows.


