git add。,git add -A和git add -u之间的区别

时间:2018-01-30 22:07:35

标签: git version-control git-add

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

  • git add。
  • git add -A
  • git add -u

我尝试执行它们并创建相同的结果。

1 个答案:

答案 0 :(得分:1)

git help add

   -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都会隐含
  • <pathspec>。(在您的问题中就是这种情况)。
  • -A将暂存更改,删除文件和添加文件。
  • -u会暂存更改并删除文件,但不是添加的文件。