git add .

他会监控工作区的状态树,使用它会把工作时的所有变化提交到暂存区,包括文件内容修改(modified)以及新文件(new),但不包括被删除的文件。

git add -u

他仅监控已经被add的文件(即tracked file),他会将被修改的文件提交到暂存区。add -u 不会提交新文件(untracked file)。(git add —update的缩写)

git add -A

是上面两个功能的合集(git add —all的缩写)

image.png
git 2.x版本之后 git add . 和 git add -A 功能基本一致了
In Git 2.x:

  • If you are located directly at the working directory, then git add -A and git add . work without the difference.
  • If you are in any subdirectory of the working directory, git add -A will add all files from the entire working directory, and git add . will add files from your current directory.

And that’s all.
from: https://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add