Skip to content

Commit 968d707

Browse files
bjornggitster
authored andcommitted
Documentation: 'git add -A' can remove files
The current documentation fails to mention that 'git add -A/--all' can remove files as well as add them, and it also does not say anything about filepatterns (whether they are allowed, mandatory, or optional). It is also not clear what the similarities and differences to the -u option are. Update the intro paragraph (as suggested by Junio, with some minor edits) to make it clear that 'git add' is able to delete and to also cover the -p option. Reword the description of -u to make it clearer (based on Björn Steinbrink's suggestion). Simplify the description of -A by saying "Like -u" and then describe the differences (based on the suggestions by Björn Steinbrink and Junio). Signed-off-by: Björn Gustavsson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa03131 commit 968d707

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

Documentation/git-add.txt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ SYNOPSIS
1414

1515
DESCRIPTION
1616
-----------
17-
This command adds the current content of new or modified files to the
18-
index, thus staging that content for inclusion in the next commit.
17+
This command updates the index using the current content found in
18+
the working tree, to prepare the content staged for the next commit.
19+
It typically adds the current content of existing paths as a whole,
20+
but with some options it can also be used to add content with
21+
only part of the changes made to the working tree files applied, or
22+
remove paths that do not exist in the working tree anymore.
1923

2024
The "index" holds a snapshot of the content of the working tree, and it
2125
is this snapshot that is taken as the contents of the next commit. Thus
@@ -92,20 +96,23 @@ apply.
9296

9397
-u::
9498
--update::
95-
Update only files that git already knows about, staging modified
96-
content for commit and marking deleted files for removal. This
97-
is similar
98-
to what "git commit -a" does in preparation for making a commit,
99-
except that the update is limited to paths specified on the
100-
command line. If no paths are specified, all tracked files in the
101-
current directory and its subdirectories are updated.
99+
Only match <filepattern> against already tracked files in
100+
the index rather than the working tree. That means that it
101+
will never stage new files, but that it will stage modified
102+
new contents of tracked files and that it will remove files
103+
from the index if the corresponding files in the working tree
104+
have been removed.
105+
+
106+
If no <filepattern> is given, default to "."; in other words,
107+
update all tracked files in the current directory and its
108+
subdirectories.
102109

103110
-A::
104111
--all::
105-
Update files that git already knows about (same as '\--update')
106-
and add all untracked files that are not ignored by '.gitignore'
107-
mechanism.
108-
112+
Like `-u`, but match <filepattern> against files in the
113+
working tree in addition to the index. That means that it
114+
will find new files as well as staging modified content and
115+
removing files that are no longer in the working tree.
109116

110117
-N::
111118
--intent-to-add::

0 commit comments

Comments
 (0)