关于版本控制:git add。,git add -A和git add -u之间的区别

Difference between git add ., git add -A and git add -u

本问题已经有最佳答案,请猛点这里访问。

这可能是一个非常基本的问题,但有人能向我解释一下这些命令之间的区别是什么:

  • Git添加。
  • Git添加-A
  • git添加-u

我试图执行它们,它们产生了相同的结果。


git help add

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
   -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, the current version of Git defaults to"."; in other words, update all files in the current
       directory and its subdirectories. This default will change in a future version of Git, hence the form without <pathspec>
       should not be used.

   -u, --update
       Update the index just where it already has an entry matching <pathspec>. This removes as well as modifies index entries to
       match the working tree, but adds no new files.

       If no <pathspec> is given, the current version of Git defaults to"."; in other words, update all tracked files in the
       current directory and its subdirectories. This default will change in a future version of Git, hence the form without
       <pathspec> should not be used.
  • 一个隐含的.-A-u)给出了在(如果这是你的问题的话)。
  • -A将舞台的变化,删除文件和补充文件。
  • 阶段的变化和-u将删除的文件,但不附加文件。