void.pointer
void.pointer

Reputation: 26335

What does `git add -A` really do?

According to the git documentation:

-A
--all
--no-ignore-removal

Update the index not only where the working tree has a file matching <pathspec> but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.

If no <pathspec> is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).

I understood this to mean that when I run git add -A subdirectory, that git effectively is doing this:

$ git update-index --again
$ git add subdirectory

However, upon doing a simple test in a local dummy git repository, it does not update files that are outside of <pathspec> but also have been staged. In fact, I can't find any difference in behavior with or without the -A option.

Can anyone explain the behavior of the -A option for git add (the git documentation's explanations are always a bit bitter to swallow)?

Upvotes: 1

Views: 95

Answers (1)

geoff_h
geoff_h

Reputation: 1253

The --no-ignore-removal is a clue. It means that if a file does not appear in your working tree but does appear in the index - e.g. if you have rmed it but not git rmed it - then it will be removed from the index (as if you had git rmed it).

Upvotes: 3

Related Questions