天天看點

git add -u與-A .三者的差別

git add -u:将檔案的修改、檔案的删除,添加到暫存區。 git add .:将檔案的修改,檔案的建立,添加到暫存區。 git add -A:将檔案的修改,檔案的删除,檔案的建立,添加到暫存區。

-u就是update的意思,隻會标記 本地有改動(包括删除和修改)的已經追蹤的檔案        -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 when -u option is used, all tracked files

           in the entire working tree are updated (old versions of Git used to

           limit the update to the current directory and its subdirectories).

-A        -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).

1.  git add -A   儲存所有的修改

2.  git add .     儲存新的添加和修改,但是不包括删除

3.  git add -u   儲存修改和删除,但是不包括建立檔案。

如圖:

git add -u與-A .三者的差別