6

When I do $ git add * sometimes I realized that git doesn't add the deleted files to the stage and I need to indicate manually if remove or add it, but I can't figure out what's the difference with $ git add --all. So if the asterisk () indicates 'everything' (), why git doesn't add all like **--all flag'?

I checked the git documentation git-add and some Difference between “git add -A” and “git add .” but doesn't specify the case when using asterisk.

Also the first answer in git add * (asterisk) vs git add . (period) indicates:

add * means add all files in the current directory, except for files, whose name begin with a dot. This is your shell functionality, actually, Git only receives a list of files.

So it means that is identically * and --all?

Thanks

Community
  • 1
  • 1
PlainOldProgrammer
  • 2,725
  • 5
  • 22
  • 30
  • `*` is expanded by the shell to all the names in the current directory. Git can't care about `*` because it never sees an asterisk, only names. – msw Nov 13 '15 at 05:14

1 Answers1

9

The difference is:

  • git add -A adds everything from the top git repo folder.
    It operates on the entire working tree, and not just on the current path.
  • git add * adds the files (as expanded by the shell, without dotfiles) from the current folder.
    It operates starting from the current path.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250