Git 2 reference · Basics

git add Command (Git)

Stage changes for the next commit: whole files, all changes, or selected hunks with -p.

Git 2

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

git add [-A] [-p] [PATHSPEC...]

Parameters

ParameterDescription
. Everything under the current directory.
-A All changes, including deletions, in the whole repository.
-p Choose hunks interactively.
-u Only already-tracked files.

Examples

Stage one file
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
echo a > a.txt; echo b > b.txt
git add a.txt
git status -s

Output

A  a.txt
?? b.txt

Run this on your computer — see “Get Started” for setup.

Stage everything, including a deletion
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
echo a > a.txt; rm README.md
git add -A
git status -s

Output

D  README.md
A  a.txt

Run this on your computer — see “Get Started” for setup.

Was this page helpful?