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
Syntax
git add [-A] [-p] [PATHSPEC...]
Parameters
| Parameter | Description |
|---|---|
. |
Everything under the current directory. |
-A |
All changes, including deletions, in the whole repository. |
-p |
Choose hunks interactively. |
-u |
Only already-tracked files. |
Examples
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.
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.
Related
git status· Show which files are staged, modified or untracked, and how the branch relates to its upstream.git commit· Record the staged changes as a new commit with a message; --amend rewrites the latest commit.git restore· Discard working-tree changes to files, or unstage files, without touching other work.- Staging and Committing · tutorial