“git add -A
” 相当于 “git add .; git add -u
“.
“git add .
“虽然看起来像是把目录下所有文件都添加,但是其实并没有,它只会添加新建和更改过的文件。
“git add -u
” 中-u代表的是update
,只会记录已有文件的update,不会记录新建的文件。
“git add -A
” 可以做上面两件事的.
你可以按照下面的命令去测试这些区别:
git init
echo Change me > change-me
echo Delete me > delete-me
git add change-me delete-me
git commit -m initial
echo OK >> change-me
rm delete-me
echo Add me > add-me
git status
# Changed but not updated:
# modified: change-me
# deleted: delete-me
# Untracked files:
# add-me
git add .
git status
# Changes to be committed:
# new file: add-me
# modified: change-me
# Changed but not updated:
# deleted: delete-me
git reset
git add -u
git status
# Changes to be committed:
# modified: change-me
# deleted: delete-me
# Untracked files:
# add-me
git reset
git add -A
git status
# Changes to be committed:
# new file: add-me
# modified: change-me
# deleted: delete-me
总结:
git add -A
?添加所有git add .
?添加新文件和修改的文件,?不包括删除的git add -u
?添加修改和和删除的文件,?不包括新增的